add version output to tie

* also reorder order of arguments for flag listing on usage+help
This commit is contained in:
justinwoo 2022-11-04 04:52:55 +02:00 committed by Alexander Biehl
parent ddf98dcac2
commit 1fa1df2a00
2 changed files with 11 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import Options.Applicative
help,
helper,
info,
infoOption,
long,
metavar,
option,
@ -28,6 +29,8 @@ import Options.Applicative
import System.Environment (getArgs)
import Tie (fileWriter, generate)
import Prelude hiding (Option)
import Data.Version (showVersion)
import Paths_tie (version)
data Input = Input
{ outputDirectory :: FilePath,
@ -78,12 +81,18 @@ options =
<> help "OpenAPI specification file"
)
versioner :: Parser (a -> a)
versioner = infoOption ("tie " <> showVersion version)
( long "version"
<> help "Print Tie version"
)
main :: IO ()
main = do
Input {..} <-
execParser $
info
(options <**> helper)
(helper <*> versioner <*> options)
( fullDesc
<> progDesc "Generate a Haskell server from an OpenAPI3 specification"
<> header "tie - openapi3 server code generator"

View File

@ -68,6 +68,7 @@ library
default-language: Haskell2010
executable tie
other-modules: Paths_tie
build-depends:
, base
, optparse-applicative