Prefix default value in help with default:
Fixes #145.
diff --git a/help.go b/help.go
index 1431b12..24a5778 100644
--- a/help.go
+++ b/help.go
@@ -204,7 +204,7 @@
var desc string
if def != "" {
- desc = fmt.Sprintf("%s (%v)%s", option.Description, def, envDef)
+ desc = fmt.Sprintf("%s (default: %v)%s", option.Description, def, envDef)
} else {
desc = option.Description + envDef
}
diff --git a/help_test.go b/help_test.go
index cd7beb4..1843cba 100644
--- a/help_test.go
+++ b/help_test.go
@@ -81,21 +81,24 @@
/c: Call phone number
/ptrslice: A slice of pointers to string
/empty-description
- /default: Test default value ("Some\nvalue")
- /default-array: Test default array value (Some
- value, "Other\tvalue")
- /default-map: Testdefault map value (some:value,
- another:value)
- /env-default1: Test env-default1 value (Some
- value) [%ENV_DEFAULT%]
+ /default: Test default value (default:
+ "Some\nvalue")
+ /default-array: Test default array value (default:
+ Some value, "Other\tvalue")
+ /default-map: Testdefault map value (default:
+ some:value, another:value)
+ /env-default1: Test env-default1 value (default:
+ Some value) [%ENV_DEFAULT%]
/env-default2: Test env-default2 value
[%ENV_DEFAULT%]
/opt-with-arg-name:something Option with named argument
/opt-with-choices:choice[dog|cat] Option with choices
Other Options:
- /s: A slice of strings (some, value)
- /intmap: A map from string to int (a:1)
+ /s: A slice of strings (default: some,
+ value)
+ /intmap: A map from string to int (default:
+ a:1)
Subgroup:
/sip.opt: This is a subgroup option
@@ -123,21 +126,24 @@
-c= Call phone number
--ptrslice= A slice of pointers to string
--empty-description
- --default= Test default value ("Some\nvalue")
- --default-array= Test default array value (Some
- value, "Other\tvalue")
- --default-map= Testdefault map value (some:value,
- another:value)
- --env-default1= Test env-default1 value (Some
- value) [$ENV_DEFAULT]
+ --default= Test default value (default:
+ "Some\nvalue")
+ --default-array= Test default array value (default:
+ Some value, "Other\tvalue")
+ --default-map= Testdefault map value (default:
+ some:value, another:value)
+ --env-default1= Test env-default1 value (default:
+ Some value) [$ENV_DEFAULT]
--env-default2= Test env-default2 value
[$ENV_DEFAULT]
--opt-with-arg-name=something Option with named argument
--opt-with-choices=choice[dog|cat] Option with choices
Other Options:
- -s= A slice of strings (some, value)
- --intmap= A map from string to int (a:1)
+ -s= A slice of strings (default: some,
+ value)
+ --intmap= A map from string to int (default:
+ a:1)
Subgroup:
--sip.opt= This is a subgroup option
diff --git a/parser.go b/parser.go
index 6f45a03..d403a40 100644
--- a/parser.go
+++ b/parser.go
@@ -162,7 +162,8 @@
//
// When the common help group has been added (AddHelp) and either -h or --help
// was specified in the command line arguments, a help message will be
-// automatically printed. Furthermore, the special error type ErrHelp is returned.
+// automatically printed if the PrintErrors option is enabled.
+// Furthermore, the special error type ErrHelp is returned.
// It is up to the caller to exit the program if so desired.
func (p *Parser) ParseArgs(args []string) ([]string, error) {
if p.internalError != nil {