Skip to content

Commit

Permalink
Show help for commands
Browse files Browse the repository at this point in the history
Unfortunately this help does not show global options; see
pcapriotti/optparse-applicative#138 .
  • Loading branch information
edsko committed Jul 8, 2015
1 parent d7eea66 commit bebcbd7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
24 changes: 15 additions & 9 deletions example-client/src/ExampleClient/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ getOptions = execParser opts
, header "Example Hackage client"
]

parseBootstrap :: Parser Command
parseBootstrap = Bootstrap <$> argument readKeyThreshold (metavar "THRESHOLD")

parseCheck :: Parser Command
parseCheck = pure Check

parseGet :: Parser Command
parseGet = Get <$> argument readPackageIdentifier (metavar "PKG")

parseGlobalOptions :: Parser GlobalOpts
parseGlobalOptions = GlobalOpts
<$> (option (str >>= readRepo) $ mconcat [
Expand Down Expand Up @@ -98,15 +107,12 @@ parseGlobalOptions = GlobalOpts
, help "Don't check expiry dates (should only be used in exceptional circumstances)"
])
<*> (subparser $ mconcat [
command "bootstrap" $
info (Bootstrap <$> argument readKeyThreshold (metavar "THRESHOLD"))
(progDesc "Get the initial root information. If using a key threshold larger than 0, you will need to use the --root-key option to specify one or more trusted root keys.")
, command "check" $
info (pure Check)
(progDesc "Check for updates")
, command "get" $
info (Get <$> argument readPackageIdentifier (metavar "PKG"))
(progDesc "Download a package")
command "bootstrap" $ info (helper <*> parseBootstrap) $
progDesc "Get the initial root information. If using a key threshold larger than 0, you will need to use the --root-key option to specify one or more trusted root keys."
, command "check" $ info (helper <*> parseCheck) $
progDesc "Check for updates"
, command "get" $ info (helper <*> parseGet) $
progDesc "Download a package"
])

readKeyId :: ReadM KeyId
Expand Down
20 changes: 10 additions & 10 deletions hackage-security-utility/src/Hackage/Security/Utility/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ parseGlobalOptions = GlobalOpts
, help "Verbose logging"
])
<*> (subparser $ mconcat [
command "create-keys" (info parseCreateKeys
(progDesc "Create keys"))
, command "bootstrap" (info parseBootstrap
(progDesc "Bootstrap a local repository"))
, command "update" (info parseUpdate
(progDesc "Update a (previously bootstrapped) local repository"))
, command "create-root" (info parseCreateRoot
(progDesc "Create root metadata"))
, command "create-mirrors" (info parseCreateMirrors
(progDesc "Create mirrors metadata. All MIRRORs specified on the command line will be written to the file."))
command "create-keys" $ info (helper <*> parseCreateKeys) $
progDesc "Create keys"
, command "bootstrap" $ info (helper <*> parseBootstrap) $
progDesc "Bootstrap a local repository"
, command "update" $ info (helper <*> parseUpdate) $
progDesc "Update a (previously bootstrapped) local repository"
, command "create-root" $ info (helper <*> parseCreateRoot) $
progDesc "Create root metadata"
, command "create-mirrors" $ info (helper <*> parseCreateMirrors) $
progDesc "Create mirrors metadata. All MIRRORs specified on the command line will be written to the file."
])

readURI :: String -> ReadM URI
Expand Down

0 comments on commit bebcbd7

Please sign in to comment.