mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
build(deps): bump github.com/urfave/cli/v3 from 3.10.0 to 3.10.1
Bumps [github.com/urfave/cli/v3](https://github.com/urfave/cli) from 3.10.0 to 3.10.1. - [Release notes](https://github.com/urfave/cli/releases) - [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md) - [Commits](https://github.com/urfave/cli/compare/v3.10.0...v3.10.1) --- updated-dependencies: - dependency-name: github.com/urfave/cli/v3 dependency-version: 3.10.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
+10
@@ -199,6 +199,12 @@ func (cmd *Command) parseFlags(args Args) (Args, error) {
|
||||
posArgs = append(posArgs, rargs...)
|
||||
return &stringSliceArgs{posArgs}, nil
|
||||
}
|
||||
// When DefaultCommand is set, pass unknown flags through as positional args
|
||||
// so the default command can handle them (fixes #2249)
|
||||
if cmd.DefaultCommand != "" {
|
||||
posArgs = append(posArgs, rargs...)
|
||||
return &stringSliceArgs{posArgs}, nil
|
||||
}
|
||||
return &stringSliceArgs{posArgs}, fmt.Errorf("%s%s", providedButNotDefinedErrMsg, flagName)
|
||||
}
|
||||
|
||||
@@ -206,6 +212,10 @@ func (cmd *Command) parseFlags(args Args) (Args, error) {
|
||||
for index, c := range flagName {
|
||||
tracef("processing flag (fName=%[1]q)", string(c))
|
||||
if sf := cmd.lookupFlag(string(c)); sf == nil {
|
||||
if index == 0 && cmd.DefaultCommand != "" {
|
||||
posArgs = append(posArgs, rargs...)
|
||||
return &stringSliceArgs{posArgs}, nil
|
||||
}
|
||||
return &stringSliceArgs{posArgs}, fmt.Errorf("%s%s", providedButNotDefinedErrMsg, flagName)
|
||||
} else if fb, ok := sf.(boolFlag); ok && fb.IsBoolFlag() {
|
||||
fv := flagVal
|
||||
|
||||
+32
@@ -99,6 +99,10 @@ func (cmd *Command) setupDefaults(osArgs []string) {
|
||||
var localVersionFlag Flag
|
||||
if globalVersionFlag, ok := VersionFlag.(*BoolFlag); ok {
|
||||
flag := *globalVersionFlag
|
||||
// Drop any alias a user flag already claims (e.g. -v
|
||||
// for --verbose) so the user flag wins but --version
|
||||
// still works. See #2229.
|
||||
flag.Aliases = dropClashingAliases(flag.Aliases, cmd.allFlags(), flag.Name)
|
||||
localVersionFlag = &flag
|
||||
} else {
|
||||
localVersionFlag = VersionFlag
|
||||
@@ -255,3 +259,31 @@ func (cmd *Command) ensureHelp() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dropClashingAliases removes aliases from `aliases` that are already
|
||||
// claimed by a flag in `userFlags` (either as a primary name or as one
|
||||
// of its own aliases). Aliases equal to `selfName` are kept so the
|
||||
// flag's primary name doesn't accidentally remove itself.
|
||||
func dropClashingAliases(aliases []string, userFlags []Flag, selfName string) []string {
|
||||
if len(aliases) == 0 || len(userFlags) == 0 {
|
||||
return aliases
|
||||
}
|
||||
taken := map[string]struct{}{}
|
||||
for _, f := range userFlags {
|
||||
for _, n := range f.Names() {
|
||||
taken[n] = struct{}{}
|
||||
}
|
||||
}
|
||||
kept := aliases[:0:0]
|
||||
for _, a := range aliases {
|
||||
if a == selfName {
|
||||
kept = append(kept, a)
|
||||
continue
|
||||
}
|
||||
if _, ok := taken[a]; ok {
|
||||
continue
|
||||
}
|
||||
kept = append(kept, a)
|
||||
}
|
||||
return kept
|
||||
}
|
||||
|
||||
+8
-2
@@ -20,6 +20,12 @@ var (
|
||||
//go:embed autocomplete
|
||||
autoCompleteFS embed.FS
|
||||
|
||||
// completionShells defines the order in which the shell completion
|
||||
// subcommands appear in help output. Iterating shellCompletions directly
|
||||
// would use Go's randomized map order, making the listing nondeterministic.
|
||||
// Keep this in sync with shellCompletions.
|
||||
completionShells = []string{"bash", "zsh", "fish", "pwsh"}
|
||||
|
||||
shellCompletions = map[string]renderCompletion{
|
||||
"bash": func(c *Command, appName string) (string, error) {
|
||||
b, err := autoCompleteFS.ReadFile("autocomplete/bash_autocomplete")
|
||||
@@ -65,8 +71,8 @@ func buildCompletionCommand(appName string) *Command {
|
||||
isCompletionCommand: true,
|
||||
}
|
||||
|
||||
for shell, render := range shellCompletions {
|
||||
cmd.Commands = append(cmd.Commands, buildShellCompletionSubcommand(shell, render, appName))
|
||||
for _, shell := range completionShells {
|
||||
cmd.Commands = append(cmd.Commands, buildShellCompletionSubcommand(shell, shellCompletions[shell], appName))
|
||||
}
|
||||
|
||||
return cmd
|
||||
|
||||
Reference in New Issue
Block a user