31 lines
809 B
Haskell
31 lines
809 B
Haskell
module CLI (
|
|
Invocation(..)
|
|
, invoked
|
|
) where
|
|
|
|
import Options.Applicative (
|
|
Parser, execParser, flag, flag', fullDesc, header, help, helper, info, long
|
|
)
|
|
import Control.Applicative ((<**>), (<|>))
|
|
import Data.Monoid ((<>))
|
|
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' Schedule
|
|
(long "schedule" <> help "Show when next to go for provisioning")
|
|
<|> flag Inventory (Version versionStr)
|
|
(long "version" <> help "Show the version number")
|
|
|
|
invoked :: IO Invocation
|
|
invoked = execParser $
|
|
info
|
|
(invocation <**> helper)
|
|
(fullDesc <> header ("Pilu v" ++ versionStr))
|