2019-04-07 18:08:22 +02:00
|
|
|
module CLI (
|
|
|
|
Invocation(..)
|
|
|
|
, invoked
|
|
|
|
) where
|
|
|
|
|
|
|
|
import Options.Applicative (
|
2019-04-14 19:20:24 +02:00
|
|
|
Parser, execParser, flag, flag', fullDesc, header, help, helper, info, long, short
|
2019-04-07 18:08:22 +02:00
|
|
|
)
|
|
|
|
import Control.Applicative ((<**>), (<|>))
|
2019-04-10 09:43:07 +02:00
|
|
|
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 =
|
2019-04-14 19:20:24 +02:00
|
|
|
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))
|