Hugo Hromic
9b5c76b1c4
Add support for setting a global env var prefix
2024-09-07 12:19:10 +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
Hugo Hromic
aa844c7de9
Fix crash on errors in package-level `MustParse`
2024-06-27 00:33:09 +01: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
68948b2ac1
restore 100% code coverage
2024-03-31 12:05:26 -04:00
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
18623d869b
help,usage and error messages and tests
2023-06-03 12:47:47 +02:00
Alex Flint
df28e7154b
clean up customizable stdout, stderr, and exit in parser config
2023-02-08 09:49:03 -05:00
Alexey Trofimov
cef66fd2f6
add strict subcommand parsing
2023-01-18 11:50:50 +03:00
Alex Flint
3d95a706a6
Merge remote-tracking branch 'origin/master' into default-value-issue
2022-10-29 15:19:23 -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
Alex Flint
197e226c77
drop unnecessary use of templates in this test
2022-10-29 12:28:06 -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
Alex Flint
ea0f540c40
update to latest go-scalar, add test for hex, oct, and binary integer literals
2022-10-02 13:05:04 -07:00
Alex Flint
23b2b67fe2
fix issue #184
2022-06-09 11:21:29 -04: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
3d59e5e89e
bump go-scalar to v1.1 and add documentation about supported types
2021-08-20 19:52:48 -07:00
Alex Flint
fa12c02e81
recurse into unexported embedded structs
2021-05-24 21:45:11 -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
01a9fab8d7
clean up environment variable tests
2021-04-19 21:22:12 -07:00
Alex Flint
fe4a138ac8
test coverage 100% !!
2021-04-19 21:03:43 -07:00
Alex Flint
bb4e7fd4b0
add unittests for maps as environment variables with the separate flag
2021-04-19 13:33:31 -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
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
17bbf2e7ef
add Config.IgnoreEnv to ignore environment variables
2020-03-01 16:32:59 -06:00
Alex Flint
cb4e079d13
add a further test
2020-01-24 14:42:49 -08:00
Alex Flint
711618869d
fix issue with duplicate fields in embedded structs
2020-01-24 14:30:29 -08:00
Andrew Morozko
c3a019cdb8
Various changes
2019-11-30 00:22:21 +03: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
Alex Flint
fcdfbc090b
fix comment
2019-08-06 16:00:13 -07:00
Alex Flint
990e87d80d
no need to initialize nil structs during path traversal
2019-05-03 16:32:16 -07:00
Alex Flint
bd97edec87
add Parser.Subcommand and Parser.SubcommandNames
2019-05-03 16:08:29 -07:00
Alex Flint
a68d6000b6
test use of --version
2019-05-02 09:47:39 -07:00
Alex Flint
93fcb0e87d
use backticks rather than backslashes in string literal
2019-05-02 09:46:11 -07:00
Alex Flint
c8c61cf8bb
add test for case where environment var is not present
2019-05-02 09:44:48 -07:00
Alex Flint
f2f7bdbbd7
add test case for missing value in middle of argument string
2019-05-02 09:39:12 -07:00
Alex Flint
4e977796af
add recursive expansion of subcommands
2019-04-30 12:54:28 -07:00
Alex Flint
7df132abe8
check error in test
2019-04-30 11:16:10 -07:00
Alex Flint
b8678d4045
refactor validation
2019-04-14 18:00:40 -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
Pavel Borzenkov
f1aabd5026
parse_test: add tests covering new TextUnamarshaler value support
...
Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
2018-11-20 12:29:36 +03:00
Pavel Borzenkov
96b097bef3
parse_test: fix formatting
...
Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
2018-11-20 12:29:15 +03:00
Illia Volochii
89714b6f48
Fix the problem with errors
2018-05-14 22:18:05 +03:00