pilu/src/CLI.hs

31 lines
814 B
Haskell
Raw Normal View History

2019-04-07 18:08:22 +02:00
module CLI (
Invocation(..)
, invoked
) where
import Options.Applicative (
Parser, execParser, flag, flag', fullDesc, header, help, helper, info, long, short
2019-04-07 18:08:22 +02:00
)
import Control.Applicative ((<**>), (<|>))
import Data.Monoid ((<>))
2019-04-07 18:08:22 +02:00
import Data.Version (showVersion)
import qualified Paths_pilu as Pilu (version)
data Invocation = Inventory | Schedule | Version String
versionStr :: String
versionStr = showVersion Pilu.version
invocation :: Parser Invocation
invocation =
flag' Inventory
(short 'i' <> long "inventory" <> help "Show a full inventory")
<|> flag Schedule (Version versionStr)
2019-04-07 18:08:22 +02:00
(long "version" <> help "Show the version number")
invoked :: IO Invocation
invoked = execParser $
info
(invocation <**> helper)
(fullDesc <> header ("Pilu v" ++ versionStr))