diff options
author | Joey Hess <joey@kitenet.net> | 2013-03-25 10:23:05 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-03-25 10:23:05 -0400 |
commit | 70912c45d126b06fe52890e26040bbd180f4f3d8 (patch) | |
tree | 9a94f3474c5c8a1fe19d6b2caf38079d22cdc533 /Usage.hs | |
parent | 98e460ec24073856f0a8ace7f4d1b28761e0be76 (diff) |
Group subcommands into sections in usage. Closes: #703797
Diffstat (limited to 'Usage.hs')
-rw-r--r-- | Usage.hs | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -18,11 +18,7 @@ usage header cmds commonoptions = unlines $ [ header , "" , "Options:" - ] ++ optlines ++ - [ "" - , "Commands:" - , "" - ] ++ cmdlines + ] ++ optlines ++ cmdlines where -- To get consistent indentation of options, generate the -- usage for all options at once. A command's options will @@ -30,12 +26,17 @@ usage header cmds commonoptions = unlines $ alloptlines = filter (not . null) $ lines $ usageInfo "" $ concatMap cmdoptions scmds ++ commonoptions - (cmdlines, optlines) = go scmds alloptlines [] - go [] os ls = (ls, os) - go (c:cs) os ls = go cs os' (ls++(l:o)) + (cmdlines, optlines) = go Nothing scmds alloptlines [] + go _ [] os ls = (ls, os) + go section (c:cs) os ls = go section' cs os' ls' where + ls' = ls++sectionheader++(l:o) + sectionheader + | section == section' = [] + | otherwise = ["", descSection (cmdsection c) ++ ":", ""] + section' = Just (cmdsection c) (o, os') = splitAt (length $ cmdoptions c) os - l = concat + l = concat [ cmdname c , namepad (cmdname c) , cmdparamdesc c |