Skip to content

Commit 321cdfe

Browse files
Add global flag '--help/-h'.
1 parent e682def commit 321cdfe

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

pkg/app/master/cli_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package app
2+
3+
import (
4+
"github.com/mintoolkit/mint/pkg/app/master/signals"
5+
"github.com/stretchr/testify/require"
6+
"testing"
7+
)
8+
9+
func TestCLI(t *testing.T) {
10+
signals.InitHandlers()
11+
cli := newCLI()
12+
13+
runArgs := [][]string{
14+
{"mint", "--version"},
15+
{"mint", "-v"},
16+
{"mint", "help"},
17+
{"mint", "-h"},
18+
}
19+
for _, args := range runArgs {
20+
require.NoError(t, cli.Run(args))
21+
}
22+
}

pkg/app/master/command/cliflags.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const (
3838
FlagCRTIOInactivityTimeout = "crt-io-inactivity-timeout"
3939
FlagCRTSaveInactivityTimeout = "crt-save-inactivity-timeout"
4040
FlagCRTCopyInactivityTimeout = "crt-copy-inactivity-timeout"
41+
FlagHelp = "help"
4142
)
4243

4344
const (
@@ -71,6 +72,7 @@ const (
7172
FlagCRTIOInactivityTimeoutUsage = "CRT I/O general inactivity timeout"
7273
FlagCRTSaveInactivityTimeoutUsage = "CRT save image operation inactivity timeout (overrides the general I/O timeout)"
7374
FlagCRTCopyInactivityTimeoutUsage = "CRT copy from container operation inactivity timeout (overrides the general I/O timeout)"
75+
FlagHelpUsage = "Show help info"
7476
)
7577

7678
// Shared command flag names
@@ -433,6 +435,11 @@ func GlobalFlags() []cli.Flag {
433435
Usage: FlagCRTCopyInactivityTimeoutUsage,
434436
EnvVars: []string{"DSLIM_CRT_COPY_INACTIVITY_TIMEOUT"},
435437
},
438+
&cli.BoolFlag{
439+
Name: FlagHelp,
440+
Aliases: []string{"h"},
441+
Usage: FlagHelpUsage,
442+
},
436443
&cli.StringFlag{
437444
Name: FlagStatePath,
438445
Value: "",

0 commit comments

Comments
 (0)