From 91c4605e6efd356ee719a290b306fefa68fc3d2d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Jul 2021 08:42:38 +0200 Subject: [PATCH] Bump github.com/alecthomas/kong from 0.2.16 to 0.2.17 (#18) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 0.2.16 to 0.2.17. - [Release notes](https://github.com/alecthomas/kong/releases) - [Commits](https://github.com/alecthomas/kong/compare/v0.2.16...v0.2.17) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 12 +++--- vendor/github.com/alecthomas/kong/README.md | 19 +++++---- vendor/github.com/alecthomas/kong/build.go | 1 + vendor/github.com/alecthomas/kong/context.go | 45 ++++++++++++-------- vendor/github.com/alecthomas/kong/go.mod | 6 +-- vendor/github.com/alecthomas/kong/go.sum | 15 +++++-- vendor/github.com/alecthomas/kong/help.go | 15 ++++++- vendor/github.com/alecthomas/kong/kong.go | 15 +++++++ vendor/github.com/alecthomas/kong/mapper.go | 3 +- vendor/github.com/alecthomas/kong/model.go | 22 ++++++++-- vendor/github.com/alecthomas/kong/options.go | 33 +++++++++++++- vendor/github.com/alecthomas/kong/tag.go | 6 +++ vendor/modules.txt | 2 +- 14 files changed, 148 insertions(+), 48 deletions(-) diff --git a/go.mod b/go.mod index 86a9c18..0cb865c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/moia-oss/aws-cfg-generator go 1.16 require ( - github.com/alecthomas/kong v0.2.16 + github.com/alecthomas/kong v0.2.17 github.com/aws/aws-sdk-go v1.38.51 github.com/rs/zerolog v1.22.0 github.com/smartystreets/goconvey v1.6.4 // indirect diff --git a/go.sum b/go.sum index c8edf82..c41431a 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/alecthomas/kong v0.2.16 h1:F232CiYSn54Tnl1sJGTeHmx4vJDNLVP2b9yCVMOQwHQ= -github.com/alecthomas/kong v0.2.16/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE= +github.com/alecthomas/kong v0.2.17 h1:URDISCI96MIgcIlQyoCAlhOmrSw6pZScBNkctg8r0W0= +github.com/alecthomas/kong v0.2.17/go.mod h1:ka3VZ8GZNPXv9Ov+j4YNLkI8mTuhXyr/0ktSlqIydQQ= github.com/aws/aws-sdk-go v1.38.51 h1:aKQmbVbwOCuQSd8+fm/MR3bq0QOsu9Q7S+/QEND36oQ= github.com/aws/aws-sdk-go v1.38.51/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -14,7 +14,6 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGw github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -27,8 +26,8 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1 github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -59,3 +58,6 @@ gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/vendor/github.com/alecthomas/kong/README.md b/vendor/github.com/alecthomas/kong/README.md index 47bd1cb..6339210 100644 --- a/vendor/github.com/alecthomas/kong/README.md +++ b/vendor/github.com/alecthomas/kong/README.md @@ -420,14 +420,14 @@ interface it will be used to decode arguments into the field. Tags can be in two forms: 1. Standard Go syntax, eg. `kong:"required,name='foo'"`. -2. Bare tags, eg. `required name:"foo"` +2. Bare tags, eg. `required:"" name:"foo"` Both can coexist with standard Tag parsing. Tag | Description -----------------------| ------------------------------------------- -`cmd` | If present, struct is a command. -`arg` | If present, field is an argument. +`cmd:""` | If present, struct is a command. +`arg:""` | If present, field is an argument. `env:"X"` | Specify envar to use for default value. `name:"X"` | Long name, for overriding field name. `help:"X"` | Help text. @@ -437,10 +437,10 @@ Tag | Description `default:"1"` | On a command, make it the default. `short:"X"` | Short name, if flag. `aliases:"X,Y"` | One or more aliases (for cmd). -`required` | If present, flag/arg is required. -`optional` | If present, flag/arg is optional. -`hidden` | If present, command or flag is hidden. -`negatable` | If present on a `bool` field, supports prefixing a flag with `--no-` to invert the default value +`required:""` | If present, flag/arg is required. +`optional:""` | If present, flag/arg is optional. +`hidden:""` | If present, command or flag is hidden. +`negatable:""` | If present on a `bool` field, supports prefixing a flag with `--no-` to invert the default value `format:"X"` | Format for parsing input, if supported. `sep:"X"` | Separator for sequences (defaults to ","). May be `none` to disable splitting. `mapsep:"X"` | Separator for maps (defaults to ";"). May be `none` to disable splitting. @@ -449,8 +449,9 @@ Tag | Description `xor:"X"` | Exclusive OR group for flags. Only one flag in the group can be used which is restricted within the same command. `prefix:"X"` | Prefix for all sub-flags. `set:"K=V"` | Set a variable for expansion by child elements. Multiples can occur. -`embed` | If present, this field's children will be embedded in the parent. Useful for composition. -`-` | Ignore the field. Useful for adding non-CLI fields to a configuration struct. +`embed:""` | If present, this field's children will be embedded in the parent. Useful for composition. +`passthrough:""` | If present, this positional argument stops flag parsing when encountered, as if `--` was processed before. Useful for external command wrappers, like `exec`. +`-` | Ignore the field. Useful for adding non-CLI fields to a configuration struct. e.g `` `kong:"-"` `` ## Plugins diff --git a/vendor/github.com/alecthomas/kong/build.go b/vendor/github.com/alecthomas/kong/build.go index 0e3bc5f..4d9081a 100644 --- a/vendor/github.com/alecthomas/kong/build.go +++ b/vendor/github.com/alecthomas/kong/build.go @@ -195,6 +195,7 @@ func buildField(k *Kong, node *Node, v reflect.Value, ft reflect.StructField, fv Tag: tag, Target: fv, Enum: tag.Enum, + Passthrough: tag.Passthrough, // Flags are optional by default, and args are required by default. Required: (!tag.Arg && tag.Required) || (tag.Arg && !tag.Optional), diff --git a/vendor/github.com/alecthomas/kong/context.go b/vendor/github.com/alecthomas/kong/context.go index 554e8b1..d132b7d 100644 --- a/vendor/github.com/alecthomas/kong/context.go +++ b/vendor/github.com/alecthomas/kong/context.go @@ -324,6 +324,21 @@ func (c *Context) Reset() error { }) } +func (c *Context) endParsing() { + args := []string{} + for { + token := c.scan.Pop() + if token.Type == EOLToken { + break + } + args = append(args, token.String()) + } + // Note: tokens must be pushed in reverse order. + for i := range args { + c.scan.PushTyped(args[len(args)-1-i], PositionalArgumentToken) + } +} + func (c *Context) trace(node *Node) (err error) { // nolint: gocyclo positional := 0 @@ -349,18 +364,7 @@ func (c *Context) trace(node *Node) (err error) { // nolint: gocyclo // Indicates end of parsing. All remaining arguments are treated as positional arguments only. case v == "--": c.scan.Pop() - args := []string{} - for { - token = c.scan.Pop() - if token.Type == EOLToken { - break - } - args = append(args, token.String()) - } - // Note: tokens must be pushed in reverse order. - for i := range args { - c.scan.PushTyped(args[len(args)-1-i], PositionalArgumentToken) - } + c.endParsing() // Long flag. case strings.HasPrefix(v, "--"): @@ -413,6 +417,11 @@ func (c *Context) trace(node *Node) (err error) { // nolint: gocyclo // Ensure we've consumed all positional arguments. if positional < len(node.Positional) { arg := node.Positional[positional] + + if arg.Passthrough { + c.endParsing() + } + err := arg.Parse(c.scan, c.getValue(arg)) if err != nil { return err @@ -626,12 +635,7 @@ func (c *Context) Apply() (string, error) { panic("unsupported path ?!") } if value != nil { - v := c.getValue(value) - if value.Flag != nil && value.Flag.Negated { - v.SetBool(!v.Bool()) - } - - value.Apply(v) + value.Apply(c.getValue(value)) } } @@ -664,6 +668,11 @@ func (c *Context) parseFlag(flags []*Flag, match string) (err error) { } return err } + if flag.Negated { + value := c.getValue(flag.Value) + value.SetBool(!value.Bool()) + flag.Value.Apply(value) + } c.Path = append(c.Path, &Path{Flag: flag}) return nil } diff --git a/vendor/github.com/alecthomas/kong/go.mod b/vendor/github.com/alecthomas/kong/go.mod index 8bbc12d..9362c5c 100644 --- a/vendor/github.com/alecthomas/kong/go.mod +++ b/vendor/github.com/alecthomas/kong/go.mod @@ -2,9 +2,9 @@ module github.com/alecthomas/kong require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/pkg/errors v0.8.1 - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/testify v1.2.2 + github.com/pkg/errors v0.9.1 + github.com/stretchr/testify v1.7.0 + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) go 1.13 diff --git a/vendor/github.com/alecthomas/kong/go.sum b/vendor/github.com/alecthomas/kong/go.sum index c935d68..d06ab36 100644 --- a/vendor/github.com/alecthomas/kong/go.sum +++ b/vendor/github.com/alecthomas/kong/go.sum @@ -1,8 +1,15 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/vendor/github.com/alecthomas/kong/help.go b/vendor/github.com/alecthomas/kong/help.go index d9f65bf..2a9985f 100644 --- a/vendor/github.com/alecthomas/kong/help.go +++ b/vendor/github.com/alecthomas/kong/help.go @@ -48,6 +48,9 @@ type HelpOptions struct { // The following exported templates can be used: kong.SpaceIndenter, kong.LineIndenter, kong.TreeIndenter // The kong.SpaceIndenter will be used by default. Indenter HelpIndenter + + // Don't show the help associated with subcommands + NoExpandSubcommands bool } // Apply options to Kong as a configuration option. @@ -62,6 +65,11 @@ type HelpProvider interface { Help() string } +// PlaceHolderProvider can be implemented by mappers to provide custom placeholder text. +type PlaceHolderProvider interface { + PlaceHolder(flag *Flag) string +} + // HelpIndenter is used to indent new layers in the help tree. type HelpIndenter func(prefix string) string @@ -180,7 +188,12 @@ func printNodeDetail(w *helpWriter, node *Node, hide bool) { if !w.FlagsLast { printFlags() } - cmds := node.Leaves(hide) + var cmds []*Node + if w.NoExpandSubcommands { + cmds = node.Children + } else { + cmds = node.Leaves(hide) + } if len(cmds) > 0 { iw := w.Indent() if w.Tree { diff --git a/vendor/github.com/alecthomas/kong/kong.go b/vendor/github.com/alecthomas/kong/kong.go index b59d61c..9c0e437 100644 --- a/vendor/github.com/alecthomas/kong/kong.go +++ b/vendor/github.com/alecthomas/kong/kong.go @@ -66,6 +66,7 @@ type Kong struct { // Set temporarily by Options. These are applied after build(). postBuildOptions []Option + dynamicCommands []*dynamicCommand } // New creates a new Kong parser on grammar. @@ -106,6 +107,20 @@ func New(grammar interface{}, options ...Option) (*Kong, error) { k.Model = model k.Model.HelpFlag = k.helpFlag + // Synthesise command nodes. + for _, dcmd := range k.dynamicCommands { + tag := newEmptyTag() + tag.Name = dcmd.name + tag.Help = dcmd.help + tag.Group = dcmd.group + tag.Cmd = true + v := reflect.Indirect(reflect.ValueOf(dcmd.cmd)) + buildChild(k, k.Model.Node, CommandNode, reflect.Value{}, reflect.StructField{ + Name: dcmd.name, + Type: v.Type(), + }, v, tag, dcmd.name, map[string]bool{}) + } + for _, option := range k.postBuildOptions { if err = option.Apply(k); err != nil { return nil, err diff --git a/vendor/github.com/alecthomas/kong/mapper.go b/vendor/github.com/alecthomas/kong/mapper.go index 7eb77fb..f5e1a3f 100644 --- a/vendor/github.com/alecthomas/kong/mapper.go +++ b/vendor/github.com/alecthomas/kong/mapper.go @@ -43,6 +43,7 @@ func (r *DecodeContext) WithScanner(scan *Scanner) *DecodeContext { } // MapperValue may be implemented by fields in order to provide custom mapping. +// Mappers may additionally implement PlaceHolderProvider to provide custom placeholder text. type MapperValue interface { Decode(ctx *DecodeContext) error } @@ -84,7 +85,7 @@ func (m *binaryUnmarshalerAdapter) Decode(ctx *DecodeContext, target reflect.Val if err != nil { return err } - if target.Type().Implements(textUnmarshalerType) { + if target.Type().Implements(binaryUnmarshalerType) { return target.Interface().(encoding.BinaryUnmarshaler).UnmarshalBinary([]byte(value)) } return target.Addr().Interface().(encoding.BinaryUnmarshaler).UnmarshalBinary([]byte(value)) diff --git a/vendor/github.com/alecthomas/kong/model.go b/vendor/github.com/alecthomas/kong/model.go index 4ce2456..da64356 100644 --- a/vendor/github.com/alecthomas/kong/model.go +++ b/vendor/github.com/alecthomas/kong/model.go @@ -146,11 +146,17 @@ func (n *Node) Summary() string { summary += " " + flags } args := []string{} + optional := 0 for _, arg := range n.Positional { - args = append(args, arg.Summary()) + argSummary := arg.Summary() + if arg.Tag.Optional { + optional++ + argSummary = strings.TrimRight(argSummary, "]") + } + args = append(args, argSummary) } if len(args) != 0 { - summary += " " + strings.Join(args, " ") + summary += " " + strings.Join(args, " ") + strings.Repeat("]", optional) } else if len(n.Children) > 0 { summary += " " } @@ -230,6 +236,7 @@ type Value struct { Set bool // Set to true when this value is set through some mechanism. Format string // Formatting directive, if applicable. Position int // Position (for positional arguments). + Passthrough bool // Set to true to stop flag parsing when encountered. } // EnumMap returns a map of the enums in this value. @@ -298,6 +305,11 @@ func (v *Value) IsBool() bool { return v.Target.Kind() == reflect.Bool } +// IsCounter returns true if the value is a counter. +func (v *Value) IsCounter() bool { + return v.Tag.Type == "counter" +} + // Parse tokens into value, parse, and validate, but do not write to the field. func (v *Value) Parse(scan *Scanner, target reflect.Value) (err error) { defer func() { @@ -377,7 +389,7 @@ func (f *Flag) String() string { if f.Short != 0 { out = fmt.Sprintf("-%c, %s", f.Short, out) } - if !f.IsBool() { + if !f.IsBool() && !f.IsCounter() { out += "=" + f.FormatPlaceHolder() } return out @@ -385,6 +397,10 @@ func (f *Flag) String() string { // FormatPlaceHolder formats the placeholder string for a Flag. func (f *Flag) FormatPlaceHolder() string { + placeholderHelper, ok := f.Value.Mapper.(PlaceHolderProvider) + if ok { + return placeholderHelper.PlaceHolder(f) + } tail := "" if f.Value.IsSlice() && f.Value.Tag.Sep != -1 { tail += string(f.Value.Tag.Sep) + "..." diff --git a/vendor/github.com/alecthomas/kong/options.go b/vendor/github.com/alecthomas/kong/options.go index ef83970..b7c4364 100644 --- a/vendor/github.com/alecthomas/kong/options.go +++ b/vendor/github.com/alecthomas/kong/options.go @@ -54,6 +54,28 @@ func Exit(exit func(int)) Option { }) } +type dynamicCommand struct { + name string + help string + group string + cmd interface{} +} + +// DynamicCommand registers a dynamically constructed command with the root of the CLI. +// +// This is useful for command-line structures that are extensible via user-provided plugins. +func DynamicCommand(name, help, group string, cmd interface{}) Option { + return OptionFunc(func(k *Kong) error { + k.dynamicCommands = append(k.dynamicCommands, &dynamicCommand{ + name: name, + help: help, + group: group, + cmd: cmd, + }) + return nil + }) +} + // NoDefaultHelp disables the default help flags. func NoDefaultHelp() Option { return OptionFunc(func(k *Kong) error { @@ -307,9 +329,16 @@ func Configuration(loader ConfigurationLoader, paths ...string) Option { return OptionFunc(func(k *Kong) error { k.loader = loader for _, path := range paths { - if _, err := os.Stat(ExpandPath(path)); os.IsNotExist(err) { - continue + f, err := os.Open(ExpandPath(path)) + if err != nil { + if os.IsNotExist(err) || os.IsPermission(err) { + continue + } + + return err } + f.Close() + resolver, err := k.LoadConfig(path) if err != nil { return errors.Wrap(err, path) diff --git a/vendor/github.com/alecthomas/kong/tag.go b/vendor/github.com/alecthomas/kong/tag.go index deffd86..4d640c9 100644 --- a/vendor/github.com/alecthomas/kong/tag.go +++ b/vendor/github.com/alecthomas/kong/tag.go @@ -34,6 +34,7 @@ type Tag struct { Embed bool Aliases []string Negatable bool + Passthrough bool // Storage for all tag keys for arbitrary lookups. items map[string][]string @@ -184,6 +185,11 @@ func parseTag(fv reflect.Value, ft reflect.StructField) *Tag { t.PlaceHolder = strings.ToUpper(dashedString(fv.Type().Name())) } t.Enum = t.Get("enum") + passthrough := t.Has("passthrough") + if passthrough && !t.Arg { + fail("passthrough only makes sense for positional arguments") + } + t.Passthrough = passthrough return t } diff --git a/vendor/modules.txt b/vendor/modules.txt index 4ee75a4..691194f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/alecthomas/kong v0.2.16 +# github.com/alecthomas/kong v0.2.17 ## explicit github.com/alecthomas/kong # github.com/aws/aws-sdk-go v1.38.51