Skip to content

Commit

Permalink
add version output to tie
Browse files Browse the repository at this point in the history
* also reorder order of arguments for flag listing on usage+help
  • Loading branch information
justinwoo authored and alexbiehl committed Nov 4, 2022
1 parent ddf98dc commit 1fa1df2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bin/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Options.Applicative
help,
helper,
info,
infoOption,
long,
metavar,
option,
Expand All @@ -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,
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tie.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ library
default-language: Haskell2010

executable tie
other-modules: Paths_tie
build-depends:
, base
, optparse-applicative
Expand Down

0 comments on commit 1fa1df2

Please sign in to comment.