Upgrading server dependancies (#8308)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
b112747de7
Коммит
6d8f122a51
25
vendor/github.com/spf13/cobra/command.go
сгенерированный
поставляемый
25
vendor/github.com/spf13/cobra/command.go
сгенерированный
поставляемый
@@ -147,6 +147,11 @@ type Command struct {
|
||||
commandsMaxNameLen int
|
||||
// commandsAreSorted defines, if command slice are sorted or not.
|
||||
commandsAreSorted bool
|
||||
// commandCalledAs is the name or alias value used to call this command.
|
||||
commandCalledAs struct {
|
||||
name string
|
||||
called bool
|
||||
}
|
||||
|
||||
// args is actual args parsed from flags.
|
||||
args []string
|
||||
@@ -557,6 +562,7 @@ func (c *Command) findNext(next string) *Command {
|
||||
matches := make([]*Command, 0)
|
||||
for _, cmd := range c.commands {
|
||||
if cmd.Name() == next || cmd.HasAlias(next) {
|
||||
cmd.commandCalledAs.name = next
|
||||
return cmd
|
||||
}
|
||||
if EnablePrefixMatching && cmd.hasNameOrAliasPrefix(next) {
|
||||
@@ -567,6 +573,7 @@ func (c *Command) findNext(next string) *Command {
|
||||
if len(matches) == 1 {
|
||||
return matches[0]
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -828,6 +835,11 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
|
||||
return c, err
|
||||
}
|
||||
|
||||
cmd.commandCalledAs.called = true
|
||||
if cmd.commandCalledAs.name == "" {
|
||||
cmd.commandCalledAs.name = cmd.Name()
|
||||
}
|
||||
|
||||
err = cmd.execute(flags)
|
||||
if err != nil {
|
||||
// Always show help if requested, even if SilenceErrors is in
|
||||
@@ -1135,14 +1147,25 @@ func (c *Command) HasAlias(s string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// CalledAs returns the command name or alias that was used to invoke
|
||||
// this command or an empty string if the command has not been called.
|
||||
func (c *Command) CalledAs() string {
|
||||
if c.commandCalledAs.called {
|
||||
return c.commandCalledAs.name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// hasNameOrAliasPrefix returns true if the Name or any of aliases start
|
||||
// with prefix
|
||||
func (c *Command) hasNameOrAliasPrefix(prefix string) bool {
|
||||
if strings.HasPrefix(c.Name(), prefix) {
|
||||
c.commandCalledAs.name = c.Name()
|
||||
return true
|
||||
}
|
||||
for _, alias := range c.Aliases {
|
||||
if strings.HasPrefix(alias, prefix) {
|
||||
c.commandCalledAs.name = alias
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -1245,7 +1268,7 @@ func (c *Command) HasParent() bool {
|
||||
return c.parent != nil
|
||||
}
|
||||
|
||||
// GlobalNormalizationFunc returns the global normalization function or nil if doesn't exists.
|
||||
// GlobalNormalizationFunc returns the global normalization function or nil if it doesn't exist.
|
||||
func (c *Command) GlobalNormalizationFunc() func(f *flag.FlagSet, name string) flag.NormalizedName {
|
||||
return c.globNormFunc
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user