117 Commits

Author SHA1 Message Date
S.Solodyagin 575a0cdf6e Merge remote-tracking branch 'upstream/master' 2025-07-02 20:54:46 +03:00
educhastenier 8e03dbeaf6 fix: broken internal link (#532)
Fix of minor broken link
2025-05-12 19:20:28 +10:00
Bob Lail 78d4066dab feat: Allow configuring global hooks via Kong's functional options (#511)
Lets you pass `kong.WithBeforeApply` along with a function that supports dynamic bindings to register a `BeforeApply` hook without tying it directly to a node in the schema.

Co-authored-by: Sutina Wipawiwat <swipawiwat@squareup.com>
2025-03-22 14:04:20 +11:00
Chris Gunn 44be791798 feat: Placeholder string interpolation. (#510)
Add support string interpolation in placeholder values.
2025-03-13 11:49:21 +11:00
Hritik Vijay 042a3258ec Document about binds with example (#491) 2025-01-25 10:51:46 +11:00
Alec Thomas 47b090f2f4 fix: add an xorprefix:"..." option for prefixing xor/and groups
Fixes #343
2024-12-29 17:55:06 +09:00
Alec Thomas a32b94b705 chore: interface{} -> any 2024-12-29 08:10:34 +09:00
Alec Thomas 840220c2ed feat: allow hooks to be declared on embedded fields
Specifically, on Go embedded fields, not on fields tagged with `embed`.

Fixes #90.
2024-12-27 22:29:45 +09:00
Alec Thomas f2fcd34abf docs: fix README TOC 2024-12-07 19:43:01 +11:00
Alec Thomas 388ba35f1a feat: add support for Provide*() (<type>, error) methods on commands 2024-12-07 17:09:03 +11:00
Alec Thomas 96647c30af feat: add old "passthrough" behaviour back in as an option
`passthrough:""` or `passthrough:"all"` (the default) will pass through
all further arguments including unrecognised flags.

`passthrough:"partial"` will validate flags up until the `--` or the
first positional argument, then pass through all subsequent flags and
arguments.
2024-12-01 20:02:03 +11:00
Alec Thomas 1b9d57eec1 feat: support optionally passing kong.Context to Validate()
Fixes #340
2024-11-03 14:14:55 +11:00
市川恭佑 (ebi) 07c8821614 Fix broken anchor link in README.md (#464) 2024-10-27 07:54:43 +11:00
Alexey Palazhchenko b34e9952de Fix Markdown in README.md (#458) 2024-09-19 18:27:07 +10:00
Alec Thomas 31301f527c docs: add note about 1.0 to README 2024-09-19 04:10:05 +10:00
Cam Hutchison 4ecb53599b Make negatable flag name customisable (#439)
* fix: Check if negatable duplicates another flag

Add a check for flags with the `negatable` option if the negative flag
conflicts with another tag, such as:

    Flag   bool `negatable:""`
    NoFlag bool

The flag `--no-flag` is ambiguous in this scenario.

* feat: Make negatable flag name customisable

Allow a value on the `negatable` tag to specify a flag name to use for
negation instead of using `--no-<flag-name>` as the flag.

e.g.

    Approve bool `default:"true",negatable:"deny"`

This example will allow `--deny` to set the `Approve` field to false.
2024-09-10 21:02:37 +10:00
Camilla 7d84b95294 Feature: Add check for overlapping xor and and groups (#443)
* Docs: Clean and group description

* Feat: Add check for overlapping xor and and groups

Co-authored-by: inful <jone.marius@vign.es>

* Chore: Rewrite overlap err to avoid duplicated words

---------

Co-authored-by: inful <jone.marius@vign.es>
2024-09-10 21:01:12 +10:00
Cole Snodgrass 6c216a37ce fix: typo in README (#451) 2024-08-21 11:55:19 +10:00
Jean-Raphaël Matte 6292953645 docs: specify usage of the placeholder tag (#448) 2024-08-13 13:05:45 +10:00
Camilla ff6d5ba7d5 Feature: Add xand tag (#442)
* Feat: Add xand group and check for missing

* Fix: Split and combine err in TestMultiand for consistency

* Feat: Check missing required flags in xand groups

* Feat: Handle combined xor and xand

* Docs: Add info about combined xand and required use

* Docs: Fix language error in xand description

Co-authored-by: Stautis <thkrst@gmail.com>

* Feat: Rename xand to and

* Refactor: Switch from fmt.Sprintf to err.Error

* Refactor: Get requiredAndGroup map in separate function

---------

Co-authored-by: Stautis <thkrst@gmail.com>
2024-08-08 16:58:22 +10:00
Ben Weintraub d315006dca Fix reference to non-existent function in README (#430) 2024-05-29 08:41:28 +10:00
s.solodyagin 6795fa089a rename 2024-04-03 20:59:37 +03:00
Prashant Varanasi fa9b636997 Support aliases for flags (#409)
Aliases are currently only supported for sub-commands, but they're
useful for flags as well. E.g., when migrating from an old flag name
to a new flag name, while still supporting the old value.
2024-02-27 11:10:15 +11:00
Abhinav Gupta 7391017a8c Drop references to io/ioutil (#403)
io/ioutil has been deprecated for a while.
Replace all uses of it with equivalent APIs.
2023-12-11 10:40:40 +11:00
Alec Thomas 2af1ea57d6 docs: add list of configuration loaders to README 2023-09-22 20:33:51 +10:00
Artem Klevtsov 1e6f15faac Add EnvFlag util (#378) 2023-09-17 09:39:43 +10:00
Denis Titusov 9610ed62d9 feat: support multiple env variables (#349) 2023-02-01 06:39:30 +11:00
Alec Thomas 919e70103f feat: add filecontent named mapper 2022-11-30 22:27:36 +11:00
Jacob Hochstetler 0c6a9f3a3d Merging issue 280 with master changes (#296) 2022-09-20 05:55:05 -07:00
noisersup 15aa6d8d4e Fix Readme.md 2022-09-17 15:11:48 +10:00
Alec Thomas 0066abb973 fix: Reset() should always be called before anything else 2022-06-15 20:45:10 +10:00
Keilin Olsen 195d56c42e Remove references to flag HelpProviders
As these don't appear to be currently supported, remove references
to them working (from main README)
2022-05-18 01:07:21 -07:00
Keilin Olsen 6042c4b10e Add example of HelpProvider + README
Relocate detailed help docs to main README
2022-05-18 01:07:21 -07:00
Keilin Olsen 1db2ea27af Move old shell/main to subdirectory
Also update README reference to same
2022-05-18 01:07:21 -07:00
pyq-lsa 5538b7f045 change help hook and call Reset later
change to BeforeResolve hook to catch calls to '--help' earlier;
call reset later in Kong.Parse() to allow help hook to get hooked;
add test;
2022-05-03 00:10:19 -07: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
leon332157 38c56226ba fix: correct line number for json example (#265) 2022-01-25 07:45:25 +11:00
Mitar a7d3850e80 Cmd can be passthrough now, too.
Fixes #253.
2022-01-05 18:58:37 +11:00
Mitar 88dcc90dde Document nested data structure. 2021-12-25 07:49:21 +11:00
Alec Thomas 9c9b8ab50b More enum fixes. 2021-12-13 18:54:06 +11:00
Alec Thomas c5e464a367 Deprecate HelpFormatter. 2021-12-03 11:48:54 +11:00
Alec Thomas 342263cb51 Fix docs re. Help() interface.
Fixes #241.
2021-11-30 21:39:35 +11:00
Dan 2770a34ce6 Add envprefix tag 2021-10-22 16:25:13 +11:00
Radon Rosborough bf5e5e843d [#88] Use reflect-compatible struct tags in examples (#202)
=
2021-09-15 16:41:30 +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 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
Alec Thomas c494f8b8f3 Support required combined with xor groups.
Fixes #112.
2021-06-21 19:25:54 +09:30
Alec Thomas 54558f65e8 Allow multiple xor:"" groups to be defined.
Fixes #113.
2021-06-21 19:04:54 +09:30
Alec Thomas c4a8cb03a7 Update docs. 2021-06-07 08:56:11 +10:00