git.iko.soy/typeable/cabal2nix
on master help sign in
Version flag
commit2a1dcac531427669f25684539b20bc8b14829e03 authorDmitry Malikov <malikov.d.y@gmail.com> dateWed 3 Dec 2014, 01:38 (12 years ago) parenta9756a3
3 files changed+13−1
cabal2nix.cabal+2 src/Cabal2Nix/Version.hs+7 src/cabal2nix.hs+4−1
cabal2nix.cabal+2
@@ -18,6 +18,7 @@ Description:
1818 .
1919 > Usage: cabal2nix [options] url-to-cabal-file-or-repo
2020 > -h --help show this help text
21+ > -v --version print version
2122 > --hackage-db=FILEPATH path to the local hackage db in tar format
2223 > --sha256=HASH sha256 hash of source tarball
2324 > -m MAINTAINER --maintainer=MAINTAINER maintainer of this package (may be specified multiple times)
@@ -69,6 +70,7 @@ Executable cabal2nix
6970 Cabal2Nix.Name
7071 Cabal2Nix.Normalize
7172 Cabal2Nix.PostProcess
73+ Cabal2Nix.Version
7274 Distribution.NixOS.Fetch
7375 Distribution.NixOS.Derivation.Cabal
7476 Distribution.NixOS.Derivation.License
src/Cabal2Nix/Version.hsnew file+7
@@ -0,0 +1,7 @@
1+module Cabal2Nix.Version where
2+
3+import Data.Version (showVersion)
4+import Paths_cabal2nix (version)
5+
6+version :: String
7+version = showVersion Paths_cabal2nix.version
src/cabal2nix.hs+4−1
@@ -3,7 +3,8 @@ module Main ( main ) where
33import Cabal2Nix.Generate ( cabal2nix )
44import Cabal2Nix.Normalize ( normalize )
55import Cabal2Nix.Package
6−import Distribution.NixOS.Derivation.Cabal
6+import Cabal2Nix.Version
7+import Distribution.NixOS.Derivation.Cabal hiding ( version )
78import Distribution.NixOS.Fetch
89
910import Control.Exception ( bracket )
@@ -47,6 +48,7 @@ defaultConfiguration = Configuration
4748options :: [OptDescr (Configuration -> Configuration)]
4849options =
4950 [ Option "h" ["help"] (NoArg (\o -> o { optPrintHelp = True })) "show this help text"
51+ , Option "v" ["version"] (NoArg (\o -> o { optPrintVersion = True })) "print version"
5052 , Option "" ["hackage-db"] (ReqArg (\x o -> o { optHackageDb = Just x }) "FILEPATH") "path to the local hackage db in tar format"
5153 , Option "" ["sha256"] (ReqArg (\x o -> o { optSha256 = Just x }) "HASH") "sha256 hash of source tarball"
5254 , Option "m" ["maintainer"] (ReqArg (\x o -> o { optMaintainer = x : optMaintainer o }) "MAINTAINER") "maintainer of this package (may be specified multiple times)"
@@ -87,6 +89,7 @@ main = bracket (return ()) (\() -> hFlush stdout >> hFlush stderr) $ \() -> do
8789 (_,_,errs) -> cmdlineError (concatMap ("*** "++) errs)
8890
8991 when (optPrintHelp cfg) (putStr usage >> exitSuccess)
92+ when (optPrintVersion cfg) (putStrLn version >> exitSuccess)
9093 when (length args /= 1) (cmdlineError "*** exactly one url-to-cabal-file must be specified\n")
9194
9295 pkg <- getPackage (optHackageDb cfg) $ Source (head args) (optRevision cfg) (optSha256 cfg)