never executed always true always false
1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE TemplateHaskell #-}
3
4 {-# OPTIONS_HADDOCK hide #-}
5
6 module Command.Version
7 ( opt
8 , run
9 ) where
10
11 import Prelude
12
13 import Data.Version
14 ( showVersion )
15 import Options.Applicative
16 ( Parser
17 , command
18 , flag'
19 , help
20 , hidden
21 , info
22 , long
23 , progDesc
24 , short
25 , subparser
26 , (<|>)
27 )
28 import Paths_cardano_addresses_cli
29 ( version )
30 import System.Git.TH
31 ( gitRevParseHEAD )
32
33 import qualified Data.ByteString.Char8 as B8
34 import qualified Data.Text as T
35 import qualified Data.Text.Encoding as T
36
37 opt :: a -> Parser a
38 opt a =
39 flag' a (mconcat
40 [ long "version"
41 , short 'v'
42 , help helpText
43 ])
44 <|>
45 subparser (mconcat
46 [ hidden
47 , command "version" $ info (pure a) (progDesc helpText)
48 ])
49 where
50 helpText = "Show the software current version and build revision."
51
52 run :: IO ()
53 run = do
54 B8.putStrLn $ T.encodeUtf8 $ T.pack $
55 showVersion version <> " @ " <> $(gitRevParseHEAD)