improve --help display for commands
This commit is contained in:
parent
60806dd191
commit
3332df2c52
2 changed files with 3 additions and 22 deletions
|
@ -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 :: CmdParams -> [Command] -> (Command -> O.Parser v) -> O.ParserResult (Command, v)
|
||||||
parseCmd allargs allcmds getparser = O.execParserPure (O.prefs O.idm) pinfo allargs
|
parseCmd allargs allcmds getparser = O.execParserPure (O.prefs O.idm) pinfo allargs
|
||||||
where
|
where
|
||||||
pinfo = O.info (O.subparser $ mconcat $ map mkcommand allcmds)
|
pinfo = O.info (O.helper <*> subcmds) O.fullDesc
|
||||||
( O.fullDesc
|
subcmds = O.subparser $ mconcat $ map mkcommand allcmds
|
||||||
<> O.progDesc "hiya"
|
|
||||||
<> O.header "ook - aaa"
|
|
||||||
)
|
|
||||||
mkcommand c = O.command (cmdname c) $ O.info (mkparser c)
|
mkcommand c = O.command (cmdname c) $ O.info (mkparser c)
|
||||||
(O.fullDesc <> O.progDesc (cmddesc c))
|
(O.fullDesc <> O.header (cmddesc c))
|
||||||
mkparser c = (,)
|
mkparser c = (,)
|
||||||
<$> pure c
|
<$> pure c
|
||||||
<*> getparser c
|
<*> getparser c
|
||||||
|
|
|
@ -10,8 +10,6 @@ module CmdLine.Usage where
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import Types.Command
|
import Types.Command
|
||||||
|
|
||||||
import System.Console.GetOpt
|
|
||||||
|
|
||||||
usageMessage :: String -> String
|
usageMessage :: String -> String
|
||||||
usageMessage s = "Usage: " ++ s
|
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
|
longest f = foldl max 0 $ map (length . f) cmds
|
||||||
scmds = sort 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. -}
|
{- Descriptions of params used in usage messages. -}
|
||||||
paramPaths :: String
|
paramPaths :: String
|
||||||
paramPaths = paramRepeating paramPath -- most often used
|
paramPaths = paramRepeating paramPath -- most often used
|
||||||
|
|
Loading…
Reference in a new issue