Commit 13756836 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Save horazontal space in the --help output by omitting options to short flags

So instead of "-f FLAGS --flags=FLAGS" we get just "-f --flags=FLAGS"
This makes rather better use of 80 cols and means the flag descriptsion
are not squeesed into such a narrow column.
parent eddcaf5b
...@@ -122,8 +122,8 @@ fmtOpt descrWidth so lo descr = ...@@ -122,8 +122,8 @@ fmtOpt descrWidth so lo descr =
fmtShort :: ArgDescr a -> Char -> String fmtShort :: ArgDescr a -> Char -> String
fmtShort (NoArg _ ) so = "-" ++ [so] fmtShort (NoArg _ ) so = "-" ++ [so]
fmtShort (ReqArg _ ad) so = "-" ++ [so] ++ " " ++ ad fmtShort (ReqArg _ _) so = "-" ++ [so]
fmtShort (OptArg _ ad) so = "-" ++ [so] ++ "[" ++ ad ++ "]" fmtShort (OptArg _ _) so = "-" ++ [so]
fmtLong :: ArgDescr a -> String -> String fmtLong :: ArgDescr a -> String -> String
fmtLong (NoArg _ ) lo = "--" ++ lo fmtLong (NoArg _ ) lo = "--" ++ lo
......
...@@ -178,8 +178,11 @@ commonFlags showOrParseArgs = case showOrParseArgs of ...@@ -178,8 +178,11 @@ commonFlags showOrParseArgs = case showOrParseArgs of
ShowArgs -> [help] ShowArgs -> [help]
ParseArgs -> [help, list] ParseArgs -> [help, list]
where where
help = GetOpt.Option ['h', '?'] ["help"] (GetOpt.NoArg HelpFlag) help = GetOpt.Option helpShortFlags ["help"] (GetOpt.NoArg HelpFlag)
"Show this help text" "Show this help text"
helpShortFlags = case showOrParseArgs of
ShowArgs -> ['h']
ParseArgs -> ['h', '?']
list = GetOpt.Option [] ["list-options"] (GetOpt.NoArg ListOptionsFlag) list = GetOpt.Option [] ["list-options"] (GetOpt.NoArg ListOptionsFlag)
"Print a list of command line flags" "Print a list of command line flags"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment