Commit Graph

343 Commits

Author SHA1 Message Date
Sebastiaan Pasterkamp ac7590cca7 feat(help): Include environment-only variables
The environment only variables don't accept command
line options, but should still be listed in the
help message.

Instead of listing the command line flags the
placeholder text '(environment only)' is displayed.
2022-12-10 15:56:01 +01:00
Sebastiaan Pasterkamp 97d1ef3a3c feat(opt groups): Add support for grouped options
Nested structs are now suppored - both pointer and
embedded. These nested structs can be presented as
option groups with their own group name and help
section.
2022-12-10 15:56:01 +01:00
Sebastiaan Pasterkamp ca8dc31b84 fix: ensure Parser.val cannot be nil
Used when adding values to subcommands as
these are undefined pointers initially.

This refactoring is in preparation of
parsing group structs later.
2022-12-10 15:56:01 +01:00
Sebastiaan Pasterkamp 00c1c8e7cd chore(parse): make parse prep a method of command
Avoid merging logic after parsing by making the
parsing function a method of the command struct
itself.

This small refactoring is in preparation of
parsing group structs later.
2022-12-10 14:24:13 +01:00
Sebastiaan Pasterkamp 23a550cfd7 fix(test): restore environment after parseWithEnv
Make sure tests don't have side-effects
potentially breaking other tests.
2022-12-10 13:55:09 +01:00
Alex Flint 727f8533ac
Merge pull request #185 from alexflint/default-value-issue
Do not turn values intro strings and then back into values when processing default values
2022-10-29 12:29:07 -07:00
Alex Flint 3489ea5b2e in a second place: use reflect.Ptr not reflect.Pointer since the latter was added in Go 1.18 2022-10-29 15:23:56 -04: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 67f7183b85 remove unused textMarshalerType and isTextMarshaler 2022-10-29 15:10:11 -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
Alex Flint 197e226c77 drop unnecessary use of templates in this test 2022-10-29 12:28:06 -04:00
Alex Flint dbc2ba5d0c
Merge pull request #198 from daenney/mustparse
Implement MustParse on Parser
2022-10-10 08:41:57 -07: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 11f9b624a9
Merge pull request #196 from alexflint/bump_go_versions
Update to latest version of Go in CI
2022-10-02 13:17:43 -07:00
Alex Flint 7f4979a06e update to latest 3 versions of Go for CI 2022-10-02 13:16:32 -07:00
Alex Flint 0c21f821f8
Merge pull request #195 from alexflint/bump_scalar_dep
Update to latest go-scalar
2022-10-02 13:07:36 -07: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 74af96c6cc
Merge pull request #191 from SebastiaanPasterkamp/add-epilog-to-help
Feat: Add epilogue after help text
2022-09-27 12:48:05 -07: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 ebd7a68a06
Merge pull request #172 from SebastiaanPasterkamp/ignore-default-option
Add 'IgnoreDefault' option
2022-06-11 09:06:03 -04: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
Alex Flint f0f44b65d1
Merge pull request #175 from alexflint/bracketing-positionals
Fix bracketing for non-required positionals in usage
2022-02-09 18:04:03 -08:00
Alex Flint 5fb236a65d fix bracketing for non-required positionals 2022-02-09 06:31:34 -08:00
Alex Flint d3706100bf
Merge pull request #173 from GreyXor/master
Update testify dependency to 1.7.0
2022-01-05 10:02:04 -05:00
GreyXor 25d4d1c864
Update go.sum 2022-01-05 15:58:54 +01:00
GreyXor 3bf2a5e78a
Update testify dependency to 1.7.0 2022-01-05 15:43:52 +01:00
Sebastiaan Pasterkamp a87d80089a Add 'IgnoreDefault' option 2022-01-02 15:17:09 +01:00
Alex Flint bf32f08247
Merge pull request #166 from alexflint/env-in-error
Put name of environment variable in error message
2021-10-01 04:44:19 -07:00
Alex Flint b47d6e3da6 put name of environment variable in error message 2021-10-01 04:35:15 -07:00
Alex Flint a4afd6a849
Merge pull request #156 from alexflint/usage-for-subcommands
add FailSubcommand, WriteUsageForSubcommand, WriteHelpForSubcommand
2021-09-18 08:57:29 -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 66cb696e79
Merge pull request #164 from evgenv123/evgenv123-patch-1
Update README.md
2021-09-18 08:53:02 -07:00
Alex Flint 0f0b4b5c3f
Update README.md 2021-09-18 08:50:33 -07:00
evgenv123 b157e8d10a
Update README.md
Hi! As a first-time user of your great package I got a little bit confused on using command line args and env vars together, so it took me some time to make testing and I propose to save this time for other people by adding relevant edits to README.md
2021-09-18 22:23:26 +07:00
Alex Flint ff38a63b36
Merge pull request #162 from alexflint/support-for-urls
Add support for URLs
2021-08-20 19:59:18 -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 eb0393e9bc
Merge pull request #158 from alexflint/unexported-embedded
Recurse into unexported embedded structs
2021-05-24 21:50:33 -07:00
Alex Flint fa12c02e81 recurse into unexported embedded structs 2021-05-24 21:45:11 -07: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 679be43af3
Merge pull request #153 from alexflint/test-empty-map
Fix case where an empty environment variable is parsed in a slice or map
2021-04-20 19:11:21 -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 9d937ba6c9
Merge pull request #152 from alexflint/mappings-with-commas
Add an example of mappings with commas
2021-04-20 12:26:56 -07:00
Alex Flint 1e81bb6866 fix the mappings-with-commas example 2021-04-20 12:23:49 -07:00
Alex Flint 4354574615
Merge pull request #151 from alexflint/fix-lint
Fix lint issue in reflect.go
2021-04-20 12:20:36 -07:00