-
Notifications
You must be signed in to change notification settings - Fork 3
/
Example.hs
35 lines (25 loc) · 988 Bytes
/
Example.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Example where
import Data.Monoid ((<>))
import Data.Text (Text, pack)
import Development.HgRev.TH (defFormat, hgRevStateTH, jsonFormat)
import Options.Applicative (Parser, ParserInfo, execParser, fullDesc,
help, helper, info, infoOption, long,
progDesc, short)
main :: IO ()
main = execParser parserInfo >> return ()
verSwitch :: Parser (a -> a)
verSwitch =
infoOption ("HG rev: " <> $(hgRevStateTH defFormat))
$ long "version"
<> short 'v'
<> help "Display version information"
jsonSwitch :: Parser (a -> a)
jsonSwitch =
infoOption $(hgRevStateTH jsonFormat)
$ long "json"
<> short 'J'
<> help "Display JSON version information"
parserInfo :: ParserInfo (a -> a)
parserInfo = info (helper <*> verSwitch <* jsonSwitch) fullDesc