From 3332df2c526d0e1306b6730f0e93413656b799b2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 8 Jul 2015 18:31:05 -0400 Subject: [PATCH] improve --help display for commands --- CmdLine.hs | 9 +++------ CmdLine/Usage.hs | 16 ---------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/CmdLine.hs b/CmdLine.hs index 89f9964b76..c61a0050cf 100644 --- a/CmdLine.hs +++ b/CmdLine.hs @@ -75,13 +75,10 @@ dispatch fuzzyok allargs allcmds commonoptions fields header getgitrepo = do parseCmd :: CmdParams -> [Command] -> (Command -> O.Parser v) -> O.ParserResult (Command, v) parseCmd allargs allcmds getparser = O.execParserPure (O.prefs O.idm) pinfo allargs where - pinfo = O.info (O.subparser $ mconcat $ map mkcommand allcmds) - ( O.fullDesc - <> O.progDesc "hiya" - <> O.header "ook - aaa" - ) + pinfo = O.info (O.helper <*> subcmds) O.fullDesc + subcmds = O.subparser $ mconcat $ map mkcommand allcmds mkcommand c = O.command (cmdname c) $ O.info (mkparser c) - (O.fullDesc <> O.progDesc (cmddesc c)) + (O.fullDesc <> O.header (cmddesc c)) mkparser c = (,) <$> pure c <*> getparser c diff --git a/CmdLine/Usage.hs b/CmdLine/Usage.hs index 1355c43162..0b1cade053 100644 --- a/CmdLine/Usage.hs +++ b/CmdLine/Usage.hs @@ -10,8 +10,6 @@ module CmdLine.Usage where import Common.Annex import Types.Command -import System.Console.GetOpt - usageMessage :: String -> String usageMessage s = "Usage: " ++ s @@ -41,20 +39,6 @@ usage header cmds = unlines $ usageMessage header : concatMap go [minBound..] longest f = foldl max 0 $ map (length . f) cmds scmds = sort cmds -{- Usage message for a single command. -} -commandUsage :: Command -> String -commandUsage cmd = unlines - [ usageInfo header (cmdoptions cmd) - , "To see additional options common to all commands, run: git annex help options" - ] - where - header = usageMessage $ unwords - [ "git-annex" - , cmdname cmd - , cmdparamdesc cmd - , "[option ...]" - ] - {- Descriptions of params used in usage messages. -} paramPaths :: String paramPaths = paramRepeating paramPath -- most often used