summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2024-07-30 19:19:25 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2024-07-30 20:29:30 +0200
commit755077c39a0dc63f07e30564df4a3121d7079da2 (patch)
treee66490bbdd284269eab40cb10ebf088f1de1de42 /src
parentec88b2eba98bac2429df00b2d9110050537f1c72 (diff)
List available commands in help text
Diffstat (limited to 'src')
-rw-r--r--src/Command.hs1
-rw-r--r--src/Command/Run.hs1
-rw-r--r--src/Main.hs15
3 files changed, 15 insertions, 2 deletions
diff --git a/src/Command.hs b/src/Command.hs
index ae24534..0ca6710 100644
--- a/src/Command.hs
+++ b/src/Command.hs
@@ -19,6 +19,7 @@ import Config
class CommandArgumentsType (CommandArguments c) => Command c where
commandName :: proxy c -> String
+ commandDescription :: proxy c -> String
type CommandOptions c :: Type
type CommandOptions c = ()
diff --git a/src/Command/Run.hs b/src/Command/Run.hs
index 677f8f1..daba8af 100644
--- a/src/Command/Run.hs
+++ b/src/Command/Run.hs
@@ -24,6 +24,7 @@ data RunCommand = RunCommand Text
instance Command RunCommand where
commandName _ = "run"
+ commandDescription _ = "Execude jobs per minici.yaml for given commits"
type CommandArguments RunCommand = Maybe Text
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