diff --git a/go.mod b/go.mod index 6b45a77..ba0fb0e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/crazy-max/undock go 1.23.0 require ( - github.com/alecthomas/kong v1.10.0 + github.com/alecthomas/kong v1.12.0 github.com/containerd/platforms v0.2.1 github.com/containers/image/v5 v5.33.1 github.com/docker/docker v27.3.1+incompatible diff --git a/go.sum b/go.sum index 3525ebb..ad80dd3 100644 --- a/go.sum +++ b/go.sum @@ -37,8 +37,8 @@ github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpH github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/kong v1.10.0 h1:8K4rGDpT7Iu+jEXCIJUeKqvpwZHbsFRoebLbnzlmrpw= -github.com/alecthomas/kong v1.10.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.12.0 h1:oKd/0fHSdajj5PfGDd3ScvEvpVJf9mT2mb5r9xYadYM= +github.com/alecthomas/kong v1.12.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= diff --git a/vendor/github.com/alecthomas/kong/README.md b/vendor/github.com/alecthomas/kong/README.md index 9f21cfe..a976332 100644 --- a/vendor/github.com/alecthomas/kong/README.md +++ b/vendor/github.com/alecthomas/kong/README.md @@ -181,7 +181,7 @@ Flags: #### Showing an _argument_'s detailed help -Custom help will only be shown for _positional arguments with named fields_ ([see the README section on positional arguments for more details on what that means](../../../README.md#branching-positional-arguments)) +Custom help will only be shown for _positional arguments with named fields_ ([see the README section on positional arguments for more details on what that means](#branching-positional-arguments)) **Contextual argument help** diff --git a/vendor/github.com/alecthomas/kong/context.go b/vendor/github.com/alecthomas/kong/context.go index 16a7353..6a4989f 100644 --- a/vendor/github.com/alecthomas/kong/context.go +++ b/vendor/github.com/alecthomas/kong/context.go @@ -99,7 +99,7 @@ type Context struct { // This just constructs a new trace. To fully apply the trace you must call Reset(), Resolve(), // Validate() and Apply(). func Trace(k *Kong, args []string) (*Context, error) { - s := Scan(args...) + s := Scan(args...).AllowHyphenPrefixedParameters(k.allowHyphenated) c := &Context{ Kong: k, Args: args, diff --git a/vendor/github.com/alecthomas/kong/kong.go b/vendor/github.com/alecthomas/kong/kong.go index 4f3901f..2334a8a 100644 --- a/vendor/github.com/alecthomas/kong/kong.go +++ b/vendor/github.com/alecthomas/kong/kong.go @@ -56,16 +56,17 @@ type Kong struct { registry *Registry ignoreFields []*regexp.Regexp - noDefaultHelp bool - usageOnError usageOnError - help HelpPrinter - shortHelp HelpPrinter - helpFormatter HelpValueFormatter - helpOptions HelpOptions - helpFlag *Flag - groups []Group - vars Vars - flagNamer func(string) string + noDefaultHelp bool + allowHyphenated bool + usageOnError usageOnError + help HelpPrinter + shortHelp HelpPrinter + helpFormatter HelpValueFormatter + helpOptions HelpOptions + helpFlag *Flag + groups []Group + vars Vars + flagNamer func(string) string // Set temporarily by Options. These are applied after build(). postBuildOptions []Option diff --git a/vendor/github.com/alecthomas/kong/levenshtein.go b/vendor/github.com/alecthomas/kong/levenshtein.go index 6837d6c..fe11745 100644 --- a/vendor/github.com/alecthomas/kong/levenshtein.go +++ b/vendor/github.com/alecthomas/kong/levenshtein.go @@ -2,8 +2,8 @@ package kong import "unicode/utf8" -// https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#Go -// License: https://creativecommons.org/licenses/by-sa/3.0/ +// Copied from https://github.com/daviddengcn/go-algs/blob/fe23fabd9d0670e4675326040ba7c285c7117b4c/ed/ed.go#L31 +// License: https://github.com/daviddengcn/go-algs/blob/fe23fabd9d0670e4675326040ba7c285c7117b4c/LICENSE func levenshtein(a, b string) int { f := make([]int, utf8.RuneCountInString(b)+1) diff --git a/vendor/github.com/alecthomas/kong/mapper.go b/vendor/github.com/alecthomas/kong/mapper.go index db3f24e..7e97836 100644 --- a/vendor/github.com/alecthomas/kong/mapper.go +++ b/vendor/github.com/alecthomas/kong/mapper.go @@ -387,7 +387,7 @@ func intDecoder(bits int) MapperFunc { //nolint: dupl default: return fmt.Errorf("expected an int but got %q (%T)", t, t.Value) } - n, err := strconv.ParseInt(sv, 10, bits) + n, err := strconv.ParseInt(sv, 0, bits) if err != nil { return fmt.Errorf("expected a valid %d bit int but got %q", bits, sv) } @@ -416,7 +416,7 @@ func uintDecoder(bits int) MapperFunc { //nolint: dupl default: return fmt.Errorf("expected an int but got %q (%T)", t, t.Value) } - n, err := strconv.ParseUint(sv, 10, bits) + n, err := strconv.ParseUint(sv, 0, bits) if err != nil { return fmt.Errorf("expected a valid %d bit uint but got %q", bits, sv) } diff --git a/vendor/github.com/alecthomas/kong/options.go b/vendor/github.com/alecthomas/kong/options.go index 5fe3532..a1fa242 100644 --- a/vendor/github.com/alecthomas/kong/options.go +++ b/vendor/github.com/alecthomas/kong/options.go @@ -55,6 +55,16 @@ func Exit(exit func(int)) Option { }) } +// WithHyphenPrefixedParameters enables or disables hyphen-prefixed parameters. +// +// These are disabled by default. +func WithHyphenPrefixedParameters(enable bool) Option { + return OptionFunc(func(k *Kong) error { + k.allowHyphenated = enable + return nil + }) +} + type embedded struct { strct any tags []string diff --git a/vendor/github.com/alecthomas/kong/scanner.go b/vendor/github.com/alecthomas/kong/scanner.go index 68f708e..511bf8f 100644 --- a/vendor/github.com/alecthomas/kong/scanner.go +++ b/vendor/github.com/alecthomas/kong/scanner.go @@ -111,7 +111,8 @@ func (t Token) IsValue() bool { // // [{FlagToken, "foo"}, {FlagValueToken, "bar"}] type Scanner struct { - args []Token + allowHyphenated bool + args []Token } // ScanAsType creates a new Scanner from args with the given type. @@ -133,6 +134,14 @@ func ScanFromTokens(tokens ...Token) *Scanner { return &Scanner{args: tokens} } +// AllowHyphenPrefixedParameters enables or disables hyphen-prefixed flag parameters on this Scanner. +// +// Disabled by default. +func (s *Scanner) AllowHyphenPrefixedParameters(enable bool) *Scanner { + s.allowHyphenated = enable + return s +} + // Len returns the number of input arguments. func (s *Scanner) Len() int { return len(s.args) @@ -162,7 +171,7 @@ func (e *expectedError) Error() string { // "context" is used to assist the user if the value can not be popped, eg. "expected value but got " func (s *Scanner) PopValue(context string) (Token, error) { t := s.Pop() - if !t.IsValue() { + if !s.allowHyphenated && !t.IsValue() { return t, &expectedError{context, t} } return t, nil diff --git a/vendor/modules.txt b/vendor/modules.txt index 691c07a..866df3c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -50,7 +50,7 @@ github.com/VividCortex/ewma # github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d ## explicit github.com/acarl005/stripansi -# github.com/alecthomas/kong v1.10.0 +# github.com/alecthomas/kong v1.12.0 ## explicit; go 1.20 github.com/alecthomas/kong # github.com/andybalholm/brotli v1.1.1