Commit Graph

18 Commits

Author SHA1 Message Date
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
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 407c8229a6 Allow "-" as a positional or flag argument.
See #70.

There are some more elaborate ideas in that issue, but I think this is
sufficient for now.
2020-04-27 09:08:33 +10:00
Alec Thomas 95de7d2f0d Produce a more useful error when flag-like values are used for flag values.
eg.  myapp: error: --log-level: expected string value but got "--foo" (long flag); perhaps try --log-level="--foo"?
2019-06-21 10:57:21 +10:00
Alec Thomas 1076f5ee1f Remove unused return value from PopValueInto. 2019-06-21 10:07:24 +10:00
Alec Thomas 439c674f7a Use interface{} instead of string in tokens.
This allows the scanner and resolvers to pass Go types around rather
than having to serialise/deserialise to/from strings.
2019-04-24 23:25:13 +10:00
Alec Thomas fddfb973d6 Clean up error handling a bit. 2018-11-03 09:49:28 +11:00
Alec Thomas 00847157a1 Ensure -- consumes all tokens, not just positional. 2018-06-23 08:13:34 +10:00
Alec Thomas 232faad0a0 Add configuration loading + docs + linter fixes. 2018-06-13 10:34:19 +10:00
Alec Thomas e9d88d6528 Implement flag "resolvers". (#24)
* Propagate errors.
* Use junit test output.
* Expand role of DecodeContext to include Scanner.
* Inject resolved flags as Path elements in the Context.
  This allows all existing logic to apply seamlessly: hooks, required
flags, etc.
* Clarify that hooks can be called multiple times.
2018-06-12 07:20:55 +10:00
Alec Thomas ab5cf7e6ef Tracing parser (#11)
* Add tracing to the parser.

* Synthesize a --help flag.

* Parsing now occurs in multiple phases.

1. Reset target.
2. Parse command-line into a "trace" (no values are written to target).
3. Apply traced, parsed values to the target fields.

This is another step in facilitating context-sensitive help and
completion.

* Detect duplicate flags.
2018-05-22 14:07:43 +10:00
Alec Thomas a41bb0e4da Remove gotestyourself. 2018-05-18 14:41:10 +10:00
Alec Thomas c6776fe4b8 Docs. 2018-05-18 13:38:07 +10:00
Alec Thomas f929749094 Add Decode() method to Value to DRY. 2018-05-17 23:50:12 +10:00
Alec Thomas 31fe51f9d8 Support cumulative positional arguments. 2018-05-17 20:16:12 +10:00
Alec Thomas b9d002b746 Slice support. 2018-05-17 19:39:48 +10:00
Alec Thomas 8f26b13088 Slice support. 2018-05-17 10:40:46 +10:00
Alec Thomas 1d00dfef7b Implemented most of the base parser.
This includes branching arguments as well as commands, eg.

    app user create <id> <first> <last>
    app user <id> delete
    app user <id> rename <to>

Of note, required/optional flags and positional arguments are not
currently enforced.
2018-05-16 20:33:18 +10:00