457 Commits

Author SHA1 Message Date
Abhinav Gupta de00f3b71c ci: Test against Go 1.20 and 1.21 (#404)
Per the [Go Release Policy][1], upstream supports
only the two most recent major releases of Go.
For example, with Go 1.21 available, only 1.21 and 1.20 are supported.
Many projects adopt a similar support policy
to strike a balance between new features and backwards support.

  [1]: https://go.dev/doc/devel/release#policy

If the project has the same policy,
it makes sense to test against both versions of Go.

This change adds a test matrix to CI,
testing against both Go 1.20 and 1.21,
on both Windows and Linux.
2023-12-11 11:03:29 +11:00
renovate[bot] 6997afd4f9 chore(deps): update actions/setup-go action to v5 (#400)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-11 10:42:05 +11:00
renovate[bot] 27806be88f chore(deps): update actions/checkout action to v4 (#399)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-11 10:41:53 +11:00
renovate[bot] d63c4d71e9 chore(deps): update module github.com/chzyer/readline to v1 (#401)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-11 10:41:39 +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
Abhinav Gupta 923c202213 hermit: Add back Go package (#402)
PR #398 looks like it deleted the Go package
so CI will revert to whatever is installed on GitHub runners by default.

Add back the Go package.
2023-12-11 10:31:04 +11:00
renovate[bot] 79809cbb47 chore(deps): update all non-major dependencies (#398)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-11 09:39:58 +11:00
Abhinav Gupta a86bda490b golangci-lint: Upgrade, fix issues (#397)
The golangci-lint being used was quite dated.
This change upgrades to the latest version.
Adds and updates exclusions based on new failures.

Note on revive:
I've included an opt-out for unused parameters for revive
because turning `newThing(required bool)` to `newThing(_ bool)`
is a loss of useful information.

The changes to the Go files are to fix the following issues:

```
camelcase.go:16: File is not `gofmt`-ed with `-s` (gofmt)
config_test.go:50:18: directive `//nolint: gosec` is unused for linter "gosec" (nolintlint)
defaults_test.go:28:25: G601: Implicit memory aliasing in for loop. (gosec)
doc.go:5: File is not `gofmt`-ed with `-s` (gofmt)
kong.go:446:18: directive `//nolint: gosec` is unused for linter "gosec" (nolintlint)
kong_test.go:503:20: G601: Implicit memory aliasing in for loop. (gosec)
model.go:493:10: composites: reflect.ValueError struct literal uses unkeyed fields (govet)
scanner.go:112: File is not `gofmt`-ed with `-s` (gofmt)
```

And to address broken nolint directives reported as follows by
golangci-lint.

```
[.. skipped .. ]
tag.go:65:1: directive `// nolint:gocyclo` should be written without leading space as `//nolint:gocyclo` (nolintlint)
tag.go:206:51: directive `// nolint: gocyclo` should be written without leading space as `//nolint: gocyclo` (nolintlint)
util_test.go:23:43: directive `// nolint: errcheck` should be written without leading space as `//nolint: errcheck` (nolintlint)
util_test.go:51:22: directive `// nolint: errcheck` should be written without leading space as `//nolint: errcheck` (nolintlint)
```
2023-12-11 09:37:07 +11:00
Abhinav Gupta 4ca2606342 mapper_windows_test: assert.NotZero for nil check (#396)
Follow up to #394, specifically [this comment][1].

  [1]: https://github.com/alecthomas/kong/pull/394#discussion_r1421683093
2023-12-10 19:40:40 +11:00
Abhinav Gupta 3263463a7e Fix Windows tests, verify in CI (#394)
* ci: Test on Windows too

Adds a Windows test run to CI.
Go setup relies on GHA for this
because Hermit doesn't yet support Windows.

* fix(mapper_windows_test): assert.NotNil => assert.True

assert.NotNil does not exist.

* filecontent mapper: Handle error from directory

If we couldn't read because the source is a directory,
override the original error message.

* fix(test): Handle platform-specific "file not found" messages
2023-12-10 15:42:50 +11:00
Alec Thomas 815ba68265 Revert "fix: set trailing positional arguments to active"
This reverts commit 575d5b1d34.
2023-12-10 08:21:36 +11:00
Alec Thomas b36879c6d4 Configure renovate 2023-12-02 12:35:56 +11:00
Alec Thomas 575d5b1d34 fix: set trailing positional arguments to active
This fixes an issue where existingfile et al would not correctly apply
to positional arguments with defaults.
2023-11-17 16:56:45 +11:00
Alec Thomas 0ecd272e23 fix: use LookupEnv to check if envar is actually set
Fixes #389
2023-11-14 09:37:35 +11:00
eli 2df767872e fix for counter type rendering as INT (#388)
closes #367
2023-11-13 17:08:13 +11:00
Jan Heuermann 93d31e17f4 Drop automatic message prefix from command errors (#384) 2023-10-07 18:15:33 +11:00
Alec Thomas 46c03841ed fix: support IsBool() on MapperValue implementations.
Fixes #381
2023-09-30 16:11:22 +08: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
Mitar 074ccd0906 fix: remove showing app name twice in errors (#368) 2023-07-21 22:08:56 +10:00
dependabot[bot] a9be85c4d3 Bump golang.org/x/crypto in /_examples/server (#352)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.0.0-20200117160349-530e935923ad to 0.1.0.
- [Release notes](https://github.com/golang/crypto/releases)
- [Commits](https://github.com/golang/crypto/commits/v0.1.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-24 17:39:03 -08:00
Denis Titusov 9610ed62d9 feat: support multiple env variables (#349) 2023-02-01 06:39:30 +11:00
Florian Loch 37e801405f fix: handle contents of tags properly by unquoting them when necessary 2023-01-26 03:52:22 +11:00
Alec Thomas 95a465b4b5 feat: add FlagNamer option
Fixes #347
2023-01-13 09:34:44 -05:00
Alec Thomas 919e70103f feat: add filecontent named mapper 2022-11-30 22:27:36 +11:00
Alec Thomas 9b08b89396 fix: ensure pointers can be detected as bools
This required adding a BoolMapperExt interface.
2022-11-26 11:21:39 +11:00
Alec Thomas bf0cbf5d7c feat: Embed() option and Context.Call()
The former allows arbitrary structs to be embedded in the root of the
CLI, with optional tags.

The latter allows an arbitrary function to be called using Kong's
binding functionality.
2022-11-22 23:34:56 +11:00
Alec Thomas d974d7270a feat: add support for camelCase JSON keys 2022-11-13 10:16:22 +11:00
Jan Heuermann 32e8ffc6fd Fix large number processing for unsigned types 2022-10-18 08:54:38 +11:00
Sever Băneșiu c62bf25854 Fix loading large integers from JSON files (#334) 2022-09-22 10:10:58 +10:00
Alec Thomas 8b826182d8 fix: tests 2022-09-21 07:33:27 +10:00
Jacob Hochstetler 0c6a9f3a3d Merging issue 280 with master changes (#296) 2022-09-20 05:55:05 -07:00
Michal Kralik 9c8b401de0 Cumulative argument needs to be last (#331) 2022-09-20 05:47:41 -07:00
noisersup 15aa6d8d4e Fix Readme.md 2022-09-17 15:11:48 +10:00
Michal Kralik 3371bd6167 fix: go1.19 specific tests for text wrapping 2022-08-26 18:53:26 +10:00
pyqlsa f48da244f5 change VersionFlag to a BeforeReset hook 2022-07-28 16:15:07 +10:00
pyqlsa a05a0c20ba Add Active member to Nodes and Values (#319) 2022-07-19 22:43:15 -07:00
Michal Kralik f9bc630ef8 Panic on duplicate command names (#317) 2022-07-17 02:31:21 -07:00
Alec Thomas 81070a043b fix: os-specific builds 2022-06-21 22:36:59 +10:00
Alec Thomas e75e1ca88a refactor: switch to alecthomas/assert 2022-06-21 20:58:10 +10:00
Alec Thomas 0066abb973 fix: Reset() should always be called before anything else 2022-06-15 20:45:10 +10:00
pyq-lsa edc47ebc34 helpful error message when flag is missing values (#310)
Fixes #277
2022-06-11 14:29:19 -07:00
James Lamb 9d72e94240 Update yaml v3 to v3.0.1 to fix CVE 2022 28948 (#309) 2022-06-09 19:16:25 -07: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 0aaa4c1199 fix: existing file/dir always checks default
updated existing file/dir mappers to early return if already set;
added tests for existing file/dir mappers;
2022-05-16 15:37:38 -07:00
David Shiflet 3c2164486d fix linux build 2022-05-16 14:14:04 -07:00
David Shiflet 29685e7da6 treat \ as escape only before a separator 2022-05-16 13:03:54 -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