Recognize --help (fixes #1441)

This commit is contained in:
Vidar Holen 2019-01-05 11:36:42 -08:00
parent 98266a1878
commit 97cb753d21
1 changed files with 10 additions and 3 deletions

View File

@ -102,10 +102,13 @@ options = [
(NoArg $ Flag "version" "true") "Print version information", (NoArg $ Flag "version" "true") "Print version information",
Option "W" ["wiki-link-count"] Option "W" ["wiki-link-count"]
(ReqArg (Flag "wiki-link-count") "NUM") (ReqArg (Flag "wiki-link-count") "NUM")
"The number of wiki links to show, when applicable.", "The number of wiki links to show, when applicable",
Option "x" ["external-sources"] Option "x" ["external-sources"]
(NoArg $ Flag "externals" "true") "Allow 'source' outside of FILES" (NoArg $ Flag "externals" "true") "Allow 'source' outside of FILES",
Option "" ["help"]
(NoArg $ Flag "help" "true") "Show this usage summary and exit"
] ]
getUsageInfo = usageInfo usageHeader options
printErr = lift . hPutStrLn stderr printErr = lift . hPutStrLn stderr
@ -114,7 +117,7 @@ parseArguments argv =
case getOpt Permute options argv of case getOpt Permute options argv of
(opts, files, []) -> return (opts, files) (opts, files, []) -> return (opts, files)
(_, _, errors) -> do (_, _, errors) -> do
printErr $ concat errors ++ "\n" ++ usageInfo usageHeader options printErr $ concat errors ++ "\n" ++ getUsageInfo
throwError SyntaxFailure throwError SyntaxFailure
formats :: FormatterOptions -> Map.Map String (IO Formatter) formats :: FormatterOptions -> Map.Map String (IO Formatter)
@ -271,6 +274,10 @@ parseOption flag options =
liftIO printVersion liftIO printVersion
throwError NoProblems throwError NoProblems
Flag "help" _ -> do
liftIO $ putStrLn getUsageInfo
throwError NoProblems
Flag "externals" _ -> Flag "externals" _ ->
return options { return options {
externalSources = True externalSources = True