MCPcopy
hub / github.com/spf13/cobra / hasNameOrAliasPrefix

Method hasNameOrAliasPrefix

command.go:1571–1583  ·  view source on GitHub ↗

hasNameOrAliasPrefix returns true if the Name or any of aliases start with prefix

(prefix string)

Source from the content-addressed store, hash-verified

1569// hasNameOrAliasPrefix returns true if the Name or any of aliases start
1570// with prefix
1571func (c *Command) hasNameOrAliasPrefix(prefix string) bool {
1572 if strings.HasPrefix(c.Name(), prefix) {
1573 c.commandCalledAs.name = c.Name()
1574 return true
1575 }
1576 for _, alias := range c.Aliases {
1577 if strings.HasPrefix(alias, prefix) {
1578 c.commandCalledAs.name = alias
1579 return true
1580 }
1581 }
1582 return false
1583}
1584
1585// NameAndAliases returns a list of the command name and all aliases
1586func (c *Command) NameAndAliases() string {

Callers 1

findNextMethod · 0.80

Calls 1

NameMethod · 0.95

Tested by

no test coverage detected