summaryrefslogtreecommitdiff
path: root/CmdLine.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-12-30 15:12:55 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-12-30 15:12:55 -0400
commitc274aadabcd1737e03003834dcf1f6bd9a79b0aa (patch)
tree8732b25a961277c49157dadc93146bfd23d30651 /CmdLine.hs
parenta89a6f21145966e625b811741d8ae972a11d92b1 (diff)
remove magic numbers
Diffstat (limited to 'CmdLine.hs')
-rw-r--r--CmdLine.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/CmdLine.hs b/CmdLine.hs
index 54c2289c6..3767fc240 100644
--- a/CmdLine.hs
+++ b/CmdLine.hs
@@ -57,9 +57,12 @@ usage header cmds options =
cmddescs = unlines $ map (indent . showcmd) cmds
showcmd c =
cmdname c ++
- pad 11 (cmdname c) ++
+ pad (commandlen + 1) (cmdname c) ++
cmdparams c ++
- pad 13 (cmdparams c) ++
+ pad (commandparamlen + 2) (cmdparams c) ++
cmddesc c
indent l = " " ++ l
pad n s = replicate (n - length s) ' '
+ longest l = foldl max 0 $ map length l
+ commandlen = longest $ map cmdname cmds
+ commandparamlen = longest $ map cmdparams cmds