Commit Graph

110 Commits

Author SHA1 Message Date
Alex Flint 0142b0b842 add subcommand aliases 2023-10-08 20:09:05 -04:00
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 259c83fd5a Remove usage of additional envOnly struct variable 2023-06-29 21:26:34 +02: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
Pablo Diaz 0280e6e591 ignores short and long parameters 2023-06-03 02:39:42 +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
Alexey Trofimov 5036dce2d6 fix typo 2023-01-18 11:52:13 +03:00
Alexey Trofimov cef66fd2f6 add strict subcommand parsing 2023-01-18 11:50:50 +03:00
Alex Flint 763072452f use reflect.Ptr not reflect.Pointer since the latter was added in Go 1.18 2022-10-29 15:21:21 -04:00
Alex Flint 3d95a706a6 Merge remote-tracking branch 'origin/master' into default-value-issue 2022-10-29 15:19:23 -04:00
Alex Flint d949871b67 add further comment about backwards-compatible method for setting default values 2022-10-29 15:13:57 -04:00
Alex Flint 9d5e97ac8a drop unnecessary test 2022-10-29 15:12:53 -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
Daniele Sluijters 4fc9666f79 Implement MustParse on Parse
This moves most of the body of the MustParse function into a MustParse
method on a Parser. The MustParse function is now implemented by calling
the MustParse function on the Parser it implicitly creates.

Closes: #194
2022-10-10 17:25:14 +02: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
Sebastiaan Pasterkamp b48371a62f Simplify sub-command initialization w/o IgnoreDefault 2022-06-05 17:54:46 +02:00
Sebastiaan Pasterkamp a87d80089a Add 'IgnoreDefault' option 2022-01-02 15:17:09 +01:00
Alex Flint b47d6e3da6 put name of environment variable in error message 2021-10-01 04:35:15 -07:00
Alex Flint f2f876420c Merge remote-tracking branch 'origin/master' into usage-for-subcommands 2021-09-18 08:55:40 -07:00
Alex Flint fa12c02e81 recurse into unexported embedded structs 2021-05-24 21:45:11 -07:00
Alex Flint c9b504edc1 add FailSubcommand, WriteUsageForSubcommand, WriteHelpForSubcommand 2021-05-09 13:55:34 -07:00
Alex Flint 2e81334206 fix case where an environment variable containing an empty string is parsed into a slice or map 2021-04-20 19:09:47 -07:00
Alex Flint fe4a138ac8 test coverage 100% !! 2021-04-19 21:03:43 -07:00
Alex Flint ccf882dca7 finish adding comments to spec 2021-04-19 13:25:11 -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 23b96d7aac refactor canParse into kindOf 2021-04-19 12:49:49 -07:00
Alex Flint 1dfefdc43e factor setSlice into its own file, add setMap, and add tests for both 2021-04-19 12:10:53 -07:00
Alex Flint 172800ff9a fix a comment 2021-04-16 20:44:18 -07:00
Alex Flint efe5cdf4da replace "name" and "typ" by storing the original StructField 2021-01-31 19:40:38 -08:00
Alex Flint 2a91531140 Merge remote-tracking branch 'origin/master' into optional-long 2021-01-31 19:20:28 -08:00
Alex Flint aa6cb95149 skip unexported fields 2021-01-31 18:29:22 -08:00
Andrew Morozko faebd3e0f2 Optional long arguments 2020-12-20 02:54:03 +03:00
Alex Flint 6be0398e80 move empty tag check inside the loop 2020-07-06 09:54:23 -07:00
Alex Flint 17bbf2e7ef add Config.IgnoreEnv to ignore environment variables 2020-03-01 16:32:59 -06:00
Alex Flint 2cc1f136b1 make sure to deep copy the field indices 2020-01-24 14:34:56 -08:00
Alex Flint 711618869d fix issue with duplicate fields in embedded structs 2020-01-24 14:30:29 -08:00
Marco Molteni 33db14a48b parse: fix typo in comment 2020-01-19 19:38:19 +01:00
Andrew Morozko c49d847704 Removed "dataname" tag 2019-11-30 00:32:28 +03: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 45d0915afc
Remove %w for compatibility with go<1.13 2019-10-21 11:42:03 -07:00
Alex Flint 84e7a764db minor cleanups 2019-10-19 23:30:33 -07:00
Alex Flint cc768447a7 store default values during NewParser 2019-10-19 23:23:32 -07:00
Alex Flint 0c95297990 add support for default values in struct tags 2019-10-08 16:39:00 -07:00
Alex Flint 233d378a50 fix issue 89 (multiple args terminated by "--") 2019-10-04 13:18:17 -07:00