cli, bin: mention -h in commands list and addons' usage messages

[ci skip]
This commit is contained in:
Simon Michael 2017-07-08 06:48:41 +01:00
parent 50977288bb
commit 6df81962ed
2 changed files with 13 additions and 10 deletions

View File

@ -423,6 +423,7 @@ checkCliOpts opts =
-- and returns a CliOpts. Or, with --help or -h present, it prints -- and returns a CliOpts. Or, with --help or -h present, it prints
-- long or short help, and exits the program. -- long or short help, and exits the program.
-- When --debug is present, also prints some debug output. -- When --debug is present, also prints some debug output.
-- Note this is not used by the main hledger executable.
-- --
-- The help texts are generated from the mode. -- The help texts are generated from the mode.
-- Long help includes the full usage description generated by cmdargs -- Long help includes the full usage description generated by cmdargs
@ -456,7 +457,7 @@ getHledgerCliOpts mode' = do
(reverse $ dropWhile null $ reverse $ takeWhile (not . ("flags:" `isInfixOf`)) $ lines longhelp) (reverse $ dropWhile null $ reverse $ takeWhile (not . ("flags:" `isInfixOf`)) $ lines longhelp)
++ ++
["" [""
," See manual for full detail, including common hledger options." -- TODO ," See also hledger -h for general hledger options."
] ]
-- | Print debug info about arguments and options if --debug is present. -- | Print debug info about arguments and options if --debug is present.
debugArgs :: [String] -> CliOpts -> IO () debugArgs :: [String] -> CliOpts -> IO ()

View File

@ -210,13 +210,14 @@ noargflagstomove = concatMap flagNames $ filter ((==FlagNone).flagInfo) flagsto
reqargflagstomove = -- filter (/= "debug") $ reqargflagstomove = -- filter (/= "debug") $
concatMap flagNames $ filter ((==FlagReq ).flagInfo) flagstomove concatMap flagNames $ filter ((==FlagReq ).flagInfo) flagstomove
-- | Template for the commands list. Includes an entry for known (or -- | Template for the commands list.
-- hypothetical) builtin and addon commands; these will be filtered -- Includes an entry for all known or hypothetical builtin and addon commands;
-- based on the commands found at runtime. COUNT is replaced with the -- these will be filtered based on the commands found at runtime.
-- number of commands found. OTHERCMDS is replaced with an entry for -- Commands beginning with "hledger" are not filtered ("hledger -h" etc.)
-- each unknown addon command found. The command descriptions here -- COUNT is replaced with the number of commands found.
-- should be synced with the commands' builtin help and the command -- OTHERCMDS is replaced with an entry for each unknown addon command found.
-- list in the hledger manual. -- The command descriptions here should be synced with each command's builtin help
-- and with hledger manual's command list.
commandsListTemplate :: String commandsListTemplate :: String
commandsListTemplate = [here|Commands available (COUNT): commandsListTemplate = [here|Commands available (COUNT):
@ -258,9 +259,9 @@ Misc:
test run some self tests test run some self tests
OTHERCMDS OTHERCMDS
Help: Help:
hledger -h show general usage
hledger CMD -h show command usage
help show any of the hledger manuals in various formats help show any of the hledger manuals in various formats
hledger CMD -h show command usage
hledger -h show general usage
|] |]
knownCommands :: [String] knownCommands :: [String]
@ -280,6 +281,7 @@ printCommandsList addonsFound = putStr commandsList
commandsFound = builtinCommandNames ++ addonsFound commandsFound = builtinCommandNames ++ addonsFound
unknownCommandsFound = addonsFound \\ knownCommands unknownCommandsFound = addonsFound \\ knownCommands
adjustline l | " hledger " `isPrefixOf` l = [l]
adjustline (' ':l) | not $ w `elem` commandsFound = [] adjustline (' ':l) | not $ w `elem` commandsFound = []
where w = takeWhile (not . (`elem` "| ")) l where w = takeWhile (not . (`elem` "| ")) l
adjustline l = [l] adjustline l = [l]