Merge pull request #342 from sv99/help-pos-required
Help for positional args without allcmd.ArgsRequired dependent from arg.Required
diff --git a/help.go b/help.go
index 55948b0..8fd3244 100644
--- a/help.go
+++ b/help.go
@@ -334,7 +334,11 @@
}
if !allcmd.ArgsRequired {
- fmt.Fprintf(wr, "[%s]", name)
+ if arg.Required > 0 {
+ fmt.Fprintf(wr, "%s", name)
+ } else {
+ fmt.Fprintf(wr, "[%s]", name)
+ }
} else {
fmt.Fprintf(wr, "%s", name)
}
diff --git a/help_test.go b/help_test.go
index 35090d8..c713bba 100644
--- a/help_test.go
+++ b/help_test.go
@@ -107,7 +107,7 @@
if runtime.GOOS == "windows" {
expected = `Usage:
- TestHelp [OPTIONS] [filename] [num] [hidden-in-help] <bommand | command | parent>
+ TestHelp [OPTIONS] [filename] [num] hidden-in-help <bommand | command | parent>
Application Options:
/v, /verbose Show verbose debug information
@@ -156,7 +156,7 @@
`
} else {
expected = `Usage:
- TestHelp [OPTIONS] [filename] [num] [hidden-in-help] <bommand | command | parent>
+ TestHelp [OPTIONS] [filename] [num] hidden-in-help <bommand | command | parent>
Application Options:
-v, --verbose Show verbose debug information