From 0ed3f76533cde17322cf04018713d70c2f78d490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 14 Feb 2024 21:44:45 +0100 Subject: Version information from git Changelog: Added -V switch to show version --- main/Main.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'main/Main.hs') diff --git a/main/Main.hs b/main/Main.hs index 72af295..3359598 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -46,14 +46,17 @@ import Erebos.Storage.Merge import Erebos.Sync import Test +import Version data Options = Options { optServer :: ServerOptions + , optShowVersion :: Bool } defaultOptions :: Options defaultOptions = Options { optServer = defaultServerOptions + , optShowVersion = False } options :: [OptDescr (Options -> Options)] @@ -64,6 +67,9 @@ options = , Option ['s'] ["silent"] (NoArg (so $ \opts -> opts { serverLocalDiscovery = False })) "do not send announce packets for local discovery" + , Option ['V'] ["version"] + (NoArg $ \opts -> opts { optShowVersion = True }) + "show version and exit" ] where so f opts = opts { optServer = f $ optServer opts } @@ -125,7 +131,10 @@ main = do (o, [], []) -> return (foldl (flip id) defaultOptions o) (_, _, errs) -> ioError (userError (concat errs ++ usageInfo header options)) where header = "Usage: erebos [OPTION...]" - interactiveLoop st opts + + if optShowVersion opts + then putStrLn versionLine + else interactiveLoop st opts interactiveLoop :: Storage -> Options -> IO () -- cgit v1.2.3