diff options
author | Joey Hess <joey@kitenet.net> | 2013-03-27 13:51:24 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-03-27 13:51:24 -0400 |
commit | d010ee969c82d6bb2d0f60c4b1ce2de3543e0920 (patch) | |
tree | fef62e7155b8ae9977ce51294339693f548cd964 /Usage.hs | |
parent | 3b1d7915569b0dbfa6cefc54e0537d19290e08bf (diff) |
Per-command usage messages.
Diffstat (limited to 'Usage.hs')
-rw-r--r-- | Usage.hs | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -11,9 +11,14 @@ import Common.Annex import Types.Command +import System.Console.GetOpt + +usageMessage :: String -> String +usageMessage s = "Usage: " ++ s + {- Usage message with lists of commands by section. -} usage :: String -> [Command] -> String -usage header cmds = unlines $ header : concatMap go [minBound..] +usage header cmds = unlines $ usageMessage header : concatMap go [minBound..] where go section | null cs = [] @@ -37,6 +42,20 @@ usage header cmds = unlines $ 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 = paramOptional $ paramRepeating paramPath -- most often used |