Skip to content

Commit 65c6dae

Browse files
frasertweedaleTristanCacqueray
authored andcommitted
tools: improve CLI help
Add descriptions for each of the subcommands. These will appear in the help/usage output. Also add `helper` (the `-h/--help` option) to two subcommands that were missing it.
1 parent 78aff06 commit 65c6dae

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

code/hsec-tools/app/Main.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ cliOpts = info (commandsParser <**> helper) (fullDesc <> header "Haskell Advisor
3030
commandsParser :: Parser (IO ())
3131
commandsParser =
3232
subparser
33-
( command "check" (info commandCheck mempty)
34-
<> command "osv" (info commandOsv mempty)
35-
<> command "render" (info commandRender mempty)
36-
<> command "generate-index" (info commandGenerateIndex mempty)
37-
<> command "help" (info commandHelp mempty)
33+
( command "check" (info commandCheck (progDesc "Syntax check a single advisory"))
34+
<> command "osv" (info commandOsv (progDesc "Convert a single advisory to OSV"))
35+
<> command "render" (info commandRender (progDesc "Render a single advisory as HTML"))
36+
<> command "generate-index" (info commandGenerateIndex (progDesc "Generate an HTML index"))
37+
<> command "help" (info commandHelp (progDesc "Show command help"))
3838
)
3939

4040
commandCheck :: Parser (IO ())
@@ -74,6 +74,7 @@ commandGenerateIndex =
7474
)
7575
<$> argument str (metavar "SOURCE-DIR")
7676
<*> argument str (metavar "DESTINATION-DIR")
77+
<**> helper
7778

7879
commandHelp :: Parser (IO ())
7980
commandHelp =
@@ -82,6 +83,7 @@ commandHelp =
8283
in void $ handleParseResult $ execParserPure defaultPrefs cliOpts args
8384
)
8485
<$> optional (argument str (metavar "COMMAND"))
86+
<**> helper
8587

8688
withAdvisory :: (Maybe FilePath -> Advisory -> IO ()) -> Maybe FilePath -> IO ()
8789
withAdvisory go file = do

0 commit comments

Comments
 (0)