diff options
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 |