let optparse-applicative handle the usage display when run w/o command or bad command
Still generating the list of commands myself, to get it sorted into sections and with short synopses.
This commit is contained in:
parent
6204dcbd7b
commit
8a9d2a6e9d
5 changed files with 42 additions and 30 deletions
|
@ -13,9 +13,12 @@ import Types.Command
|
|||
usageMessage :: String -> String
|
||||
usageMessage s = "Usage: " ++ s
|
||||
|
||||
{- Usage message with lists of commands by section. -}
|
||||
usage :: String -> [Command] -> String
|
||||
usage header cmds = unlines $ usageMessage header : concatMap go [minBound..]
|
||||
usage header cmds = unlines $ usageMessage header : commandList cmds
|
||||
|
||||
{- Commands listed by section, with breif usage and description. -}
|
||||
commandList :: [Command] -> [String]
|
||||
commandList cmds = concatMap go [minBound..]
|
||||
where
|
||||
go section
|
||||
| null cs = []
|
||||
|
@ -39,6 +42,7 @@ usage header cmds = unlines $ usageMessage header : concatMap go [minBound..]
|
|||
longest f = foldl max 0 $ map (length . f) cmds
|
||||
scmds = sort cmds
|
||||
|
||||
|
||||
{- Descriptions of params used in usage messages. -}
|
||||
paramPaths :: String
|
||||
paramPaths = paramRepeating paramPath -- most often used
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue