Hugo Hromic
c73f38cd54
Improve handling of version flag
...
* Only use/show builtin `--version` flag if args are versioned with a non-empty `Version()`
* If args define a `--version` flag, honor it and disable/hide the builtin version flag
* Only return `ErrVersion` when using the builtin version flag
2023-07-14 20:12:52 +01:00
Ilja Neumann
18623d869b
help,usage and error messages and tests
2023-06-03 12:47:47 +02:00
Ilja Neumann
ccf62e0ffc
don't print env-vars in usage line
2023-06-03 03:33:10 +02:00
Pablo Diaz
5f10667949
fixed tests
2023-06-03 02:39:56 +02:00
Pablo Diaz
c3cac76438
added tests and fixed usage
2023-06-03 02:39:56 +02:00
Alex Flint
df28e7154b
clean up customizable stdout, stderr, and exit in parser config
2023-02-08 09:49:03 -05:00
duxinlong
efae1938fd
feat: support more env than terminal
...
Change-Id: I7f35e90b8f19f4ea781832885d35e2f1e275207a
2023-02-08 12:01:48 +00:00
Alex Flint
3d95a706a6
Merge remote-tracking branch 'origin/master' into default-value-issue
2022-10-29 15:19:23 -04:00
Alex Flint
522dbbcea8
add test for the new default value parsing logic as it shows up in help messages
2022-10-29 15:08:48 -04:00
Sebastiaan Pasterkamp
c8b9567d1b
Feat: Add epilog after help text
...
Similar to the Description at the top of the
help text an Epilog is added at the bottom.
Resolves #189
2022-09-17 12:55:00 +02:00
Alex Flint
5fb236a65d
fix bracketing for non-required positionals
2022-02-09 06:31:34 -08:00
Alex Flint
7cc8da61cf
simplify the error string logic
2021-05-09 14:01:08 -07:00
Alex Flint
c9b504edc1
add FailSubcommand, WriteUsageForSubcommand, WriteHelpForSubcommand
2021-05-09 13:55:34 -07:00
Alex Flint
fe4a138ac8
test coverage 100% !!
2021-04-19 21:03:43 -07:00
Alex Flint
9949860eb3
change "kind" to "cardinality", add support for maps to parser
2021-04-19 13:21:04 -07:00
Alex Flint
f4eb7f3a58
Merge pull request #137 from alexflint/optional-long
...
Optional long names
2021-04-16 21:03:14 -07:00
LeoZhan
4f2ab5c009
refactor: remove unused function
2021-04-08 00:20:56 +08:00
Alex Flint
788c166025
test that short-only options are printed first in the help message
2021-01-31 19:15:49 -08:00
Andrew Morozko
438a91dba1
Skip right column if the left is empty
2020-12-20 03:51:33 +03:00
Andrew Morozko
faebd3e0f2
Optional long arguments
2020-12-20 02:54:03 +03:00
Denys Vitali
d4bb56e096
feat(usage): Include env variable in usage
2020-06-03 10:05:20 +02:00
Dylan Allbee
c24567c12e
Fix lint warnings
2020-01-25 11:53:34 -08:00
Dylan Allbee
5df19ebe00
Use command passed into p.Parse(...) write methods
...
It is currently impossible to programatically write help and usage
messages for subcommands, due to parser.WriteHelp and parser.WriteUsage
not taking the state of the parser into account.
Check for the existence of p.lastCmd and use it for the writers when
available.
Enables ability to write unit tests for subcommand help.
2020-01-25 11:53:34 -08:00
Dylan Allbee
338e831a84
Print global options in help for subcommands
...
fixes #101
2020-01-25 11:53:34 -08:00
Marco Molteni
9f5522668a
address review comments
2020-01-23 16:35:45 +01:00
Marco Molteni
cfd894f446
usage: if the program supports subcommands, mention it
2020-01-19 19:40:53 +01:00
Andrew Morozko
c3a019cdb8
Various changes
2019-11-30 00:22:21 +03:00
Andrew Morozko
904e039267
Added the "dataname" tag
2019-11-29 22:33:16 +03:00
Alex Flint
cc768447a7
store default values during NewParser
2019-10-19 23:23:32 -07:00
Alex Flint
990e87d80d
no need to initialize nil structs during path traversal
2019-05-03 16:32:16 -07:00
Alex Flint
3c5e61a292
simplify Fprint call
2019-05-03 15:50:41 -07:00
Alex Flint
b83047068d
print help and usage at subcommand level if necessary
2019-05-03 15:49:44 -07:00
Alex Flint
15bf383f1d
add subcommands to usage string
2019-05-03 15:02:10 -07:00
Alex Flint
af12b7cfc2
introduced path struct
2019-04-30 13:30:23 -07:00
Alex Flint
ddec9e9e4f
rename get/settable to readable/writable
2019-04-30 11:40:11 -07:00
Alex Flint
f282f71f26
minor reformat
2019-04-30 11:16:01 -07:00
Alex Flint
e2dda40825
all tests passing again
2019-04-14 19:50:17 -07:00
Alex Flint
b8678d4045
refactor validation
2019-04-14 18:00:40 -07:00
Wlazlo, Matt
d4cc703210
Custom parsers implementing encoding.TextMarshaler() can have default values printed via --help
2018-04-13 14:46:24 +10:00
Mario Hros
58e62faa3d
required positional args
2017-03-30 20:32:39 +02:00
Mario Hros
9173d259ef
nicer usage output
2017-03-08 20:44:01 +01:00
Emmanouil "Manolis" Maragkakis
9030aa1348
print description in help message, not in usage
2017-02-08 11:41:07 -05:00
Emmanouil "Manolis" Maragkakis
db27431153
add support for description string
2017-01-23 20:41:12 -05:00
Alex Flint
c453aa1a28
add support for version string
2016-09-08 21:18:19 -07:00
Fredrik Wallgren
e71d6514f4
Print defaults for multiples
...
Check if the default value supplied is a slice and not nil, if so
print the list of values supplied.
Test case for slice argument with and without default values.
Default values for slices was not printed because slice is not
comparable, but the zero value for slices is nil.
2016-03-06 21:07:01 +01:00
Alex Flint
aaae1550b7
Merge pull request #32 from alexflint/override_program_name
...
make it possible to override the name of the program
2016-02-22 06:39:41 -08:00
Alex Flint
e389d7f782
add support for IP address, email address, and MAC address
2016-01-23 20:49:57 -08:00
Alex Flint
b1ec8c9093
make it possible to override the name of the program
2016-01-18 10:31:01 -08:00
Alex Flint
4197d283e4
extract common colWidth constant
2016-01-18 08:24:21 -08:00
Alex Flint
77be03b907
resolve merge
2016-01-18 08:19:10 -08:00