mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-07 21:15:19 +03:00
make --help and -h the same, drop --man and --info for now (#579)
This commit is contained in:
parent
23c77a3ae8
commit
7e896572a7
@ -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
|
||||
|
11
doc/lib.m4
11
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
|
||||
|
||||
|
@ -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_({{
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 ()
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user