summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--erebos-tester.cabal1
-rw-r--r--src/Main.hs12
2 files changed, 13 insertions, 0 deletions
diff --git a/erebos-tester.cabal b/erebos-tester.cabal
index 47c3639..1819223 100644
--- a/erebos-tester.cabal
+++ b/erebos-tester.cabal
@@ -38,6 +38,7 @@ executable erebos-tester-core
Network
Output
Parser
+ Paths_erebos_tester
Process
Run.Monad
Test
diff --git a/src/Main.hs b/src/Main.hs
index 98fa9f1..e90aa79 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -28,6 +28,9 @@ import System.Posix.Process
import System.Posix.Signals
import System.Process
+import Paths_erebos_tester (version)
+import Data.Version (showVersion)
+
import Config
import GDB
import Network
@@ -337,12 +340,14 @@ runTest out opts test = do
data CmdlineOptions = CmdlineOptions
{ optTest :: TestOptions
+ , optShowVersion :: Bool
, optVerbose :: Bool
}
defaultCmdlineOptions :: CmdlineOptions
defaultCmdlineOptions = CmdlineOptions
{ optTest = defaultTestOptions
+ , optShowVersion = False
, optVerbose = False
}
@@ -368,6 +373,9 @@ options =
, Option ['f'] ["force"]
(NoArg $ to $ \opts -> opts { optForce = True })
"remove test directory if it exists instead of stopping"
+ , Option ['V'] ["version"]
+ (NoArg $ \opts -> opts { optShowVersion = True })
+ "show version and exit"
]
where
to f opts = opts { optTest = f (optTest opts) }
@@ -394,6 +402,10 @@ main = do
(_, _, errs) -> ioError (userError (concat errs ++ usageInfo header options))
where header = "Usage: erebos-tester [OPTION...]"
+ when (optShowVersion opts) $ do
+ putStrLn $ "Erebos Tester version " <> showVersion version
+ exitSuccess
+
getPermissions (head $ words $ optDefaultTool $ optTest opts) >>= \perms -> do
when (not $ executable perms) $ do
fail $ optDefaultTool (optTest opts) <> " is not executable"