Commit Graph

54 Commits

Author SHA1 Message Date
Alex Flint d10a064207
Merge pull request #262 from hhromic/fix-261
Fix help text for positional args with default and env var
2024-09-05 17:20:09 -04:00
Hugo Hromic bf156d17a3
Fix help text for positional args with default and env var 2024-07-22 19:25:51 +01:00
Hugo Hromic 3673177bf9
Move writing program version from usage to help writer
* Writing the version on usage text is unexpected and confusing
2024-07-06 11:52:47 +01:00
Alex Flint 0cc152dce5
Merge pull request #224 from hhromic/better-version-v2
Fix usage writing when using custom version flag
2024-06-30 12:27:39 -04:00
Hugo Hromic c992aa8627
Add more test cases for version help/usage writing 2024-06-30 00:12:34 +01:00
Hugo Hromic a7c40c36a3
Use standard exit status code for usage errors
* The stdlib `flags` package and most command line utilities use status code `2`.
2024-06-29 15:44:50 +01:00
Alex Flint dfca71d159
Merge pull request #243 from alexflint/handle-empty-placeholder
Handle explicit empty placeholders
2024-04-02 12:16:06 -04:00
Alex Flint 188bd31bf6
Merge pull request #244 from alexflint/restore-100pct-coverage
Restore 100% test coverage
2024-04-02 12:14:49 -04:00
Alex Flint 8a917260c3 add a test case with single-level subcommands 2024-04-02 12:10:52 -04:00
Alex Flint 3ddfffdcd3 add test for help and usage when a --version flag is present 2024-04-02 12:05:00 -04:00
Alex Flint 8e35a4f0d4 handle explicit empty placeholders 2024-03-31 10:30:12 -04:00
Alex Flint 0142b0b842 add subcommand aliases 2023-10-08 20:09:05 -04:00
Ilja Neumann 18623d869b help,usage and error messages and tests 2023-06-03 12:47:47 +02:00
Ilja Neumann b928a1839a Parse env-only vars 2023-06-03 09:50:42 +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
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
Alex Flint 27c832b934 store both a default value and a string representation of that default value in the spec for each option 2022-10-29 14:47:13 -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 23b2b67fe2 fix issue #184 2022-06-09 11:21:29 -04:00
Alex Flint 5fb236a65d fix bracketing for non-required positionals 2022-02-09 06:31:34 -08: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 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
Alex Flint 063a48797d clean up extraneous test output 2020-04-03 11:52:00 -04:00
Alex Flint 17bbf2e7ef add Config.IgnoreEnv to ignore environment variables 2020-03-01 16:32:59 -06: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
Alex Flint cc768447a7 store default values during NewParser 2019-10-19 23:23:32 -07:00
Alex Flint 6b4ab7355c add golangci badge, and fix some lint issues found by the tool 2019-04-04 09:10:24 -07:00
Wlazlo, Matt 51337ded77 fixed example comment, test coverage issue 2018-04-16 11:07:48 +10:00
Wlazlo, Matt d4cc703210 Custom parsers implementing encoding.TextMarshaler() can have default values printed via --help 2018-04-13 14:46:24 +10:00
Rick ba9514f0be Further clarification 2017-10-02 14:36:23 +01:00
Rick d7961941f0 Altered help tag parsing to reduce the constraints on help text content; old behaviour is retained for backward compatibility 2017-10-02 14:18:41 +01:00
Mario Hros 992acaf408 tests 2017-03-30 20:47:59 +02:00
Mario Hros 9173d259ef nicer usage output 2017-03-08 20:44:01 +01: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
brettlangdon 8dd29d34bf Add support for environment variables 2016-01-18 13:42:04 -05:00
Alex Flint b1ec8c9093 make it possible to override the name of the program 2016-01-18 10:31:01 -08:00
Alex Flint 77be03b907 resolve merge 2016-01-18 08:19:10 -08:00
Alex Rakoczy e4e9e19427 Fix error when printing usage for multi-value arguments
We try to compare []strings, which are uncomparable types:

`panic: runtime error: comparing uncomparable type []string`
2015-12-04 09:59:13 -05:00
brettlangdon d45bd4523c Display help text for positional arguments 2015-11-21 18:59:40 -05:00