From 7e896572a75f06193132f095c577b14aa6d6f7ef Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 7 Jul 2017 02:00:46 +0100 Subject: [PATCH] make --help and -h the same, drop --man and --info for now (#579) --- bin/hledger-budget.hs | 2 +- doc/lib.m4 | 11 +---------- hledger-api/doc/hledger-api.1.m4.md | 11 +---------- hledger-api/hledger-api.hs | 12 +++--------- hledger-ui/Hledger/UI/Main.hs | 5 +---- hledger-web/Hledger/Web/Main.hs | 5 +---- hledger/Hledger/Cli/CliOptions.hs | 13 +++++-------- hledger/Hledger/Cli/Main.hs | 21 ++++++++++----------- 8 files changed, 23 insertions(+), 57 deletions(-) diff --git a/bin/hledger-budget.hs b/bin/hledger-budget.hs index 892224f28..2e852028c 100755 --- a/bin/hledger-budget.hs +++ b/bin/hledger-budget.hs @@ -239,6 +239,6 @@ main = do rawopts <- fmap decodeRawOpts . processArgs $ cmdmode opts <- rawOptsToCliOpts rawopts case find (\e -> command_ opts `elem` modeNames (fst e)) actions of - Just (amode, _) | "h" `elem` map fst (rawopts_ opts) -> print amode + Just (amode, _) | "help" `elem` map fst (rawopts_ opts) -> print amode Just (_, action) -> action opts Nothing -> print cmdmode diff --git a/doc/lib.m4 b/doc/lib.m4 index b7e6c72df..7f22a15e0 100644 --- a/doc/lib.m4 +++ b/doc/lib.m4 @@ -67,18 +67,9 @@ m4_define({{_timedot_}}, {{```timedot$1```}} )m4_dnl m4_dnl m4_define({{_helpoptions_}}, {{ -`-h` +`-h --help` : show general usage (or after COMMAND, command usage) -`--help` -: show this program's manual as plain text (or after an add-on COMMAND, the add-on's manual) - -`--man` -: show this program's manual with man - -`--info` -: show this program's manual with info - `--version` : show version diff --git a/hledger-api/doc/hledger-api.1.m4.md b/hledger-api/doc/hledger-api.1.m4.md index 81c8e5ac7..4ad0f0605 100644 --- a/hledger-api/doc/hledger-api.1.m4.md +++ b/hledger-api/doc/hledger-api.1.m4.md @@ -60,18 +60,9 @@ Note: if invoking hledger-api as a hledger subcommand, write `--` before options `--version` : show version -`-h` +`-h --help` : show usage -`--help` -: show manual as plain text - -`--man` -: show manual with man - -`--info` -: show manual with info - _man_({{ diff --git a/hledger-api/hledger-api.hs b/hledger-api/hledger-api.hs index 3e94096ea..579f0e8ce 100644 --- a/hledger-api/hledger-api.hs +++ b/hledger-api/hledger-api.hs @@ -50,7 +50,7 @@ Usage: hledger-api --swagger print API docs in Swagger 2.0 format hledger-api --version - hledger-api -h|--help|--man|--info + hledger-api -h|--help Options: -f --file FILE use a different input file @@ -60,10 +60,7 @@ Options: --host IPADDR listen on this IP address (default: 127.0.0.1) -p --port PORT listen on this TCP port (default: 8001) --version show version - -h show usage - --help show manual - --man show manual with man - --info show manual with info + -h --help show usage |] swaggerSpec :: Swagger @@ -76,10 +73,7 @@ swaggerSpec = toSwagger (Proxy :: Proxy HledgerApi) main :: IO () main = do args <- getArgs >>= parseArgsOrExit doc - when (isPresent args (shortOption 'h')) $ exitWithUsage doc - when (isPresent args (longOption "help")) $ printHelpForTopic "api" >> exitSuccess - when (isPresent args (longOption "man")) $ runManForTopic "api" >> exitSuccess - when (isPresent args (longOption "info")) $ runInfoForTopic "api" >> exitSuccess + when (isPresent args (shortOption 'h') || isPresent args (longOption "help")) $ exitWithUsage doc when (isPresent args (longOption "version")) $ putStrLn hledgerApiVersion >> exitSuccess when (isPresent args (longOption "swagger")) $ BL8.putStrLn (encode swaggerSpec) >> exitSuccess let diff --git a/hledger-ui/Hledger/UI/Main.hs b/hledger-ui/Hledger/UI/Main.hs index 59fa50470..4327c2b69 100644 --- a/hledger-ui/Hledger/UI/Main.hs +++ b/hledger-ui/Hledger/UI/Main.hs @@ -66,10 +66,7 @@ main = do run opts where run opts - | "h" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeUsage uimode) >> exitSuccess - | "help" `inRawOpts` (rawopts_ $ cliopts_ opts) = printHelpForTopic (topicForMode uimode) >> exitSuccess - | "man" `inRawOpts` (rawopts_ $ cliopts_ opts) = runManForTopic (topicForMode uimode) >> exitSuccess - | "info" `inRawOpts` (rawopts_ $ cliopts_ opts) = runInfoForTopic (topicForMode uimode) >> exitSuccess + | "help" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeUsage uimode) >> exitSuccess | "version" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn prognameandversion >> exitSuccess | "binary-filename" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn (binaryfilename progname) | otherwise = withJournalDoUICommand opts runBrickUi diff --git a/hledger-web/Hledger/Web/Main.hs b/hledger-web/Hledger/Web/Main.hs index 0d8daaa2e..c6396780d 100644 --- a/hledger-web/Hledger/Web/Main.hs +++ b/hledger-web/Hledger/Web/Main.hs @@ -43,10 +43,7 @@ hledgerWebMain = do runWith :: WebOpts -> IO () runWith opts - | "h" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeUsage webmode) >> exitSuccess - | "help" `inRawOpts` (rawopts_ $ cliopts_ opts) = printHelpForTopic (topicForMode webmode) >> exitSuccess - | "man" `inRawOpts` (rawopts_ $ cliopts_ opts) = runManForTopic (topicForMode webmode) >> exitSuccess - | "info" `inRawOpts` (rawopts_ $ cliopts_ opts) = runInfoForTopic (topicForMode webmode) >> exitSuccess + | "help" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeUsage webmode) >> exitSuccess | "version" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn prognameandversion >> exitSuccess | "binary-filename" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn (binaryfilename progname) | otherwise = do diff --git a/hledger/Hledger/Cli/CliOptions.hs b/hledger/Hledger/Cli/CliOptions.hs index 1a95040fa..fe2a1c34c 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -102,10 +102,7 @@ import Hledger.Cli.Version -- | Common help flags: --help, --debug, --version... helpflags :: [Flag RawOpts] helpflags = [ - flagNone ["h"] (setboolopt "h") "show general usage (or after CMD, command usage)" - ,flagNone ["help"] (setboolopt "help") "show this program's manual as plain text (or after an addon CMD, the add-on's manual)" - ,flagNone ["man"] (setboolopt "man") "show this program's manual with man" - ,flagNone ["info"] (setboolopt "info") "show this program's manual with info" + flagNone ["help","h"] (setboolopt "help") "show general usage (or after CMD, command usage)" -- ,flagNone ["browse-args"] (setboolopt "browse-args") "use a web UI to select options and build up a command line" ,flagReq ["debug"] (\s opts -> Right $ setopt "debug" s opts) "[N]" "show debug output (levels 1-9, default: 1)" ,flagNone ["version"] (setboolopt "version") "show version information" @@ -200,7 +197,7 @@ defCommandMode names = defMode { ,modeGroupFlags = Group { groupNamed = [] ,groupUnnamed = [ - flagNone ["h"] (setboolopt "h") "Show usage." + flagNone ["help"] (setboolopt "help") "Show usage." -- ,flagNone ["help"] (setboolopt "help") "Show long help." ] ,groupHidden = [] -- flags not displayed in the usage @@ -447,8 +444,8 @@ getHledgerCliOpts mode' = do let rawopts = either usageError decodeRawOpts $ process mode' args' opts <- rawOptsToCliOpts rawopts debugArgs args' opts - when ("help" `inRawOpts` rawopts_ opts) $ putStr longhelp >> exitSuccess - when ("h" `inRawOpts` rawopts_ opts) $ putStr shorthelp >> exitSuccess + when ("help" `inRawOpts` rawopts_ opts) $ putStr shorthelp >> exitSuccess + -- when ("help" `inRawOpts` rawopts_ opts) $ putStr longhelp >> exitSuccess return opts where longhelp = showModeUsage mode' @@ -457,7 +454,7 @@ getHledgerCliOpts mode' = do (reverse $ dropWhile null $ reverse $ takeWhile (not . ("flags:" `isInfixOf`)) $ lines longhelp) ++ ["" - ," See --help for full detail, including common hledger options." + ," See manual for full detail, including common hledger options." -- TODO ] -- | Print debug info about arguments and options if --debug is present. debugArgs :: [String] -> CliOpts -> IO () diff --git a/hledger/Hledger/Cli/Main.hs b/hledger/Hledger/Cli/Main.hs index 569e793d8..2d6f78d4b 100644 --- a/hledger/Hledger/Cli/Main.hs +++ b/hledger/Hledger/Cli/Main.hs @@ -127,15 +127,12 @@ mainmode addons = defMode { PROGNAME list commands PROGNAME CMD [--] [OPTS] [ARGS] run a command (use -- with addon commands) PROGNAME-CMD [OPTS] [ARGS] or run addon commands directly -PROGNAME -h general usage -PROGNAME CMD -h command usage -PROGNAME --help PROGNAME manual -PROGNAME --man PROGNAME manual as man page -PROGNAME --info PROGNAME manual as info manual -PROGNAME help list help topics -PROGNAME help TOPIC TOPIC manual -PROGNAME man TOPIC TOPIC manual as man page -PROGNAME info TOPIC TOPIC manual as info manual +PROGNAME -h show general usage +PROGNAME CMD -h show command usage +PROGNAME help list available manuals +PROGNAME help MANUAL show a manual as plain text +PROGNAME man MANUAL show a manual as man page +PROGNAME info MANUAL show a manual as info manual |] } @@ -264,8 +261,10 @@ Misc: rewrite add automated postings to certain transactions test run some self tests OTHERCMDS -Help: (see also -h, CMD -h, --help|--man|--info) - help|man|info show any of the hledger manuals in text/man/info format +Help: + hledger -h show general usage + hledger CMD -h show command usage + help|man|info show any of the hledger manuals in plain text/man/info format |] knownCommands :: [String]