diff --git a/hledger-api/hledger-api.hs b/hledger-api/hledger-api.hs index ae6b1a5bb..a570e4134 100644 --- a/hledger-api/hledger-api.hs +++ b/hledger-api/hledger-api.hs @@ -57,7 +57,8 @@ Options: (default: .) -p --port PORT use a different TCP port (default: 8001) --version show version - -h --help show this help + -h show usage + --help show detailed help |] swaggerSpec :: Swagger @@ -70,7 +71,8 @@ swaggerSpec = toSwagger (Proxy :: Proxy HledgerApi) main :: IO () main = do args <- getArgs >>= parseArgsOrExit doc - when (isPresent args (longOption "help")) $ exitWithUsage doc + when (isPresent args (shortOption 'h')) $ exitWithUsage doc + when (isPresent args (longOption "help")) $ putStr (lookupDocTxt "api") >> exitSuccess when (isPresent args (longOption "version")) $ putStrLn hledgerApiVersion >> exitSuccess when (isPresent args (longOption "swagger")) $ BL8.putStrLn (encode swaggerSpec) >> exitSuccess let defp = "8001" diff --git a/hledger-ui/Hledger/UI/Main.hs b/hledger-ui/Hledger/UI/Main.hs index ab832130a..d12fde3ab 100644 --- a/hledger-ui/Hledger/UI/Main.hs +++ b/hledger-ui/Hledger/UI/Main.hs @@ -42,7 +42,8 @@ main = do run opts where run opts - | "help" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeHelp uimode) >> exitSuccess + | "shorthelp" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeUsage uimode) >> exitSuccess + | "longhelp" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeHelp 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 e6f965cf6..33281eff1 100644 --- a/hledger-web/Hledger/Web/Main.hs +++ b/hledger-web/Hledger/Web/Main.hs @@ -43,7 +43,8 @@ hledgerWebMain = do runWith :: WebOpts -> IO () runWith opts - | "help" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeHelp webmode) >> exitSuccess + | "shorthelp" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeUsage webmode) >> exitSuccess + | "longhelp" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeHelp 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 08f05de90..261a4a6e4 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -230,10 +230,16 @@ showModeUsage :: Mode a -> String showModeUsage = (showText defaultWrap :: [Text] -> String) . (helpText [] HelpFormatDefault :: Mode a -> [Text]) --- | Get a mode's long help, ready for console output --- (currently, the hledger man page formatted for 80 columns). +-- | Get a mode's long help, ready for console output. Currently that +-- will be the hledger, hledger-ui, hledger-web or hledger-api man page, +-- formatted for 80 columns. showModeHelp :: Mode a -> String -showModeHelp _ = lookupDocTxt "cli" +showModeHelp m + | n == "hledger-ui" = lookupDocTxt "ui" + | n == "hledger-web" = lookupDocTxt "web" + -- | n == "hledger-api" = lookupDocTxt "api" -- hledger-api uses docopt + | otherwise = lookupDocTxt "cli" + where n = headDef "" $ modeNames m -- | Add command aliases to the command's help string. withAliases :: String -> [String] -> String