diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2024-07-30 19:19:25 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2024-07-30 20:29:30 +0200 |
commit | 755077c39a0dc63f07e30564df4a3121d7079da2 (patch) | |
tree | e66490bbdd284269eab40cb10ebf088f1de1de42 /src/Main.hs | |
parent | ec88b2eba98bac2429df00b2d9110050537f1c72 (diff) |
List available commands in help text
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Main.hs b/src/Main.hs index 7dcc484..cdce0f9 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -61,8 +61,19 @@ main = do exitFailure when (optShowHelp opts) $ do - let header = "Usage: minici [<option>...] <command> [<args>]" - putStr $ usageInfo header options + let header = "Usage: minici [<option>...] <command> [<args>]\n\nCommon options are:" + commandDesc (SC proxy) = " " <> padCommand (commandName proxy) <> commandDescription proxy + + padTo n str = str <> replicate (n - length str) ' ' + padCommand = padTo (maxCommandNameLength + 3) + commandNameLength (SC proxy) = length $ commandName proxy + maxCommandNameLength = maximum $ map commandNameLength commands + + putStr $ usageInfo header options <> unlines ( + [ "" + , "Available commands:" + ] ++ map commandDesc commands + ) exitSuccess when (optShowVersion opts) $ do |