457 Commits

Author SHA1 Message Date
Alec Thomas 7c6ff10d33 fix: values that look like flags would not be parsed correctly
Specifically, when parsing into slices or maps.

Fixes #290
2022-04-08 06:43:08 +10:00
Alec Thomas 556f8b773b chore: pin Go-1.17.8 2022-03-18 18:56:02 +11:00
Denis Titusov 89b2806f6a Switch to the standard errors API, that was introduced in 1.13 (#273)
* Switch to the standard errors API, that was introduced in 1.13

* Fix linter errors 🤦‍

* Remove withStackError

* fix: freeze go version to 1.17, since 1.18 introduced generics, which are not supported by linters yet

* fix: freeze go version to 1.17, since 1.18 introduced generics, which are not supported by linters yet
2022-03-18 18:54:29 +11:00
Alec Thomas 7a63525420 feat: AutoGroup option 2022-03-11 22:51:12 +11:00
hasheddan 1939f2cda0 Remove extraneous + in README.md
Removes + characters that were included from a previous diff.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2022-02-27 11:14:26 +11:00
Ali Eren Öztürk cc81f03a38 Support listing enums in specified order (#274) 2022-02-21 21:36:14 +11:00
Alec Thomas 72024dd44a fix: hydrate pointer fields
It is a mystery how this has been a bug for so long.
2022-02-16 13:26:29 +11:00
pyq-lsa ab085f771e fix required/xor behavior w/ > 2 flags 2022-01-30 09:13:18 +11:00
Denis Titusov e49700181c fix: Change the application flags order avoiding panics
This commit solves issue alecthomas/kong#264
2022-01-27 22:52:55 +11:00
leon332157 38c56226ba fix: correct line number for json example (#265) 2022-01-25 07:45:25 +11:00
Alec Thomas 3987efba86 fix: issue with symlinked temp dirs 2022-01-05 20:01:51 +11:00
Mitar a7d3850e80 Cmd can be passthrough now, too.
Fixes #253.
2022-01-05 18:58:37 +11:00
Mitar 76d5ed9ac1 Small improvements to ChangeDirFlag. 2022-01-04 08:29:23 +11:00
Mitar f5bd1465d8 Add ChangeToFlag to allow changing the current working directory. 2022-01-03 15:47:31 +11:00
Mitar 88dcc90dde Document nested data structure. 2021-12-25 07:49:21 +11:00
Alec Thomas 7533b11d06 Differentiate between omitted and empty default.
Fixes #250.
2021-12-13 19:03:23 +11:00
Alec Thomas 9c9b8ab50b More enum fixes. 2021-12-13 18:54:06 +11:00
Alec Thomas fa08e7027c fix: overly enthusiastic validation of tags 2021-12-13 16:48:21 +11:00
Mitar ece1f6d8cb Allow more flexible callback return error type. 2021-12-13 12:00:13 +11:00
Mitar deebf0b09b Do not add environment variable to help it is already present.
Fixes #246.
2021-12-05 06:23:18 +11:00
Alec Thomas 32b2f740c9 Support $$ for escaping $ in interpolated values.
Fixes #248
2021-12-04 21:06:33 +11:00
Alec Thomas c5e464a367 Deprecate HelpFormatter. 2021-12-03 11:48:54 +11:00
Mitar c3703cda7e Fix that default should not override the placeholder.
Fixes #243.
2021-12-02 23:06:44 +11:00
Alec Thomas d564bd286f Add test for #244. 2021-12-02 12:59:34 +11:00
Alec Thomas 342263cb51 Fix docs re. Help() interface.
Fixes #241.
2021-11-30 21:39:35 +11:00
Colin ff839dc6db Fix env var interpolation (#236) 2021-11-24 13:57:08 +11:00
Nate Parsons f00d33b57c Use reflect-compatible struct tags in examples 2021-11-23 15:19:08 +11:00
Colin 79f896f0c0 feat: add support for variable interpolation into env tag key (#234) 2021-11-19 08:56:39 +11:00
Connor Hindley 5090305bcb Add help testcase for envprefix + no env. 2021-11-19 06:22:36 +11:00
Connor Hindley ea18c73f11 Only prepend EnvPrefix if .Env is not empty.
Before this change the EnvPrefix was applied to fields without env
specified, which resulted in strange and confusing help output.
2021-11-19 06:22:36 +11:00
Dan 2770a34ce6 Add envprefix tag 2021-10-22 16:25:13 +11:00
Grant Monroe 749d3f0752 Allow root application to have a Run(...) error method.
Issue #209
2021-10-15 15:47:17 +11:00
Alec Thomas 5c7b038540 Rename IgnoreFieldsRegex -> IgnoreFields. 2021-09-27 16:31:54 +10:00
Alec Thomas 1d48b6f720 Allow Mappers to contribute Vars to interpolation.
See #218.
2021-09-27 16:07:48 +10:00
Dilip Somavarapu dd18549686 Update Help.go to make Sub Commands can be Hidden (#207) 2021-09-17 08:21:21 +10:00
Radon Rosborough bf5e5e843d [#88] Use reflect-compatible struct tags in examples (#202)
=
2021-09-15 16:41:30 +10:00
Stan Rozenraukh 74cb5130e3 Adds Context.BindToProvider (#201) 2021-08-31 06:47:02 +10:00
Alec Thomas d0c0180cec Hydrate pointers to embedded structs. 2021-08-28 16:54:55 +10:00
Daniel Selans 07faa2e0d0 Add ability to ignore fields that match given regex pattern(s) (#199) 2021-08-28 15:41:08 +10:00
Alec Thomas dd904ce961 Upgrade golangci-lint. 2021-08-27 20:58:22 +10:00
Alec Thomas 43616c6a6d Hydrate sub-commands that are pointers.
Fixes #196.
2021-08-27 20:57:38 +10:00
Yunchi Luo b5bcf3579b Support duration as nanosecond number when using a resolver
Duration is always marshaled as a nanosecond number when using JSON. Kong would only parse it as a string using ParseDuration. Now it can use the number version too.
2021-08-27 04:31:39 +10:00
Simon Frei 5a9c9c7864 Bubble errors instead of panicking (#194) 2021-08-19 18:00:53 +10:00
Nikita Semikov f547618963 Add aliases to ALL help output (#191) 2021-08-07 22:04:51 +10:00
Alec Thomas 676890f22f Switch to GHA. 2021-08-01 14:45:09 +10:00
Alec Thomas d1a818b5a1 Allow DynamicCommand to specify arbitrary tags.
Fixes #185.
2021-07-13 13:55:01 +10:00
Cam Hutchison 89315e74ad Allow default commands with cmds/args/flags (#188)
* Move default command validation to build

Move the validation of default commands - checking if a node has
multiple default commands or a default command has children - to the
build phase rather than tracing. These errors are with the structure of
the CLI ast and are detectable before parsing the command line.

Add a couple of tests for some of the default command error cases.

* Disallow positional args on a default command

Do not allow a default command to have positional arguments. The current
check is only for branching args, but the error message implies that
positional args are not allowed either. So add a check for positional
args too, and add a test case for it.

This is breaking change to the API but is unlikely to have ill-effect as
positional args on a default command cannot be used without explicitly
naming the command (i.e. not using it as a default).

* Allow default commands with cmds/args/flags

Allow default commands to have sub-commands, args and flags when tagged
with `default:"withargs"`. This makes specifying the name of the
command on the CLI completely optional as long as the args to that
command are not ambiguous with other commands.
2021-07-12 14:19:37 +10:00
Alec Thomas cfbe844aa4 Fix xor + required combo.
See #112.
2021-07-11 21:23:18 +10:00
Evgeny 8b2821cc24 Added sub objects support in JSON resolver (#178) 2021-06-21 21:08:43 +10:00
Alec Thomas 247574041d Enum fields must be required or have a default.
This is a breaking change, but the previous behaviour was broken so I'm
not concerned.

Also made most programmer errors more useful by giving type.field
context information.

Fixes #179.
2021-06-21 20:35:41 +09:30