diff --git a/package.yaml b/package.yaml index a25ba9a89a24ad35ab11213e0b38848a349393b0..beffc205ce1727fcbbd1e353b1742a0b0be42536 100644 --- a/package.yaml +++ b/package.yaml @@ -32,6 +32,7 @@ dependencies: - dbus - directory - filepath +- gitrev - hostname - lens - mtl diff --git a/src/QBar/Cli.hs b/src/QBar/Cli.hs index af1d19ea6fdb95ac31546538c18b4623e3a3bac9..c1febf9351497a3d43a9a2ef263fcb7280535060 100644 --- a/src/QBar/Cli.hs +++ b/src/QBar/Cli.hs @@ -1,4 +1,5 @@ {-# LANGUAGE ApplicativeDo #-} +{-# LANGUAGE TemplateHaskell #-} module QBar.Cli where @@ -15,6 +16,7 @@ import QBar.Time import Control.Monad (join) import Data.Maybe (fromMaybe) import qualified Data.Text.Lazy as T +import Development.GitRev import Options.Applicative -- |Entry point. @@ -31,12 +33,18 @@ parseMain = customExecParser parserPrefs parser parserPrefs :: ParserPrefs parserPrefs = prefs showHelpOnEmpty +versionInformation :: String +versionInformation = "Branch: " <> $gitBranch <> "\n" + <> "Commit: " <> $gitHash <> (if $gitDirty then " (dirty)" else "") <> "\n" + <> "Commit date: " <> $gitCommitDate + mainParser :: Parser (IO ()) mainParser = do verbose <- switch $ long "verbose" <> short 'v' <> help "Print more diagnostic output to stderr (including a copy of every bar update)." indicator <- switch $ long "indicator" <> short 'i' <> help "Show render indicator." socketLocation <- optional $ strOption $ long "socket" <> short 's' <> metavar "SOCKET" <> help "Control socket location. By default determined by WAYLAND_SOCKET location." barCommand <- barCommandParser + infoOption versionInformation $ long "version" <> help "Shows version information about the executable." return (barCommand MainOptions {verbose, indicator, socketLocation}) barCommandParser :: Parser (MainOptions -> IO ())