mirror of
https://github.com/spf13/cobra
synced 2025-05-06 13:27:26 +00:00
deal with unreachable code warning.
This commit is contained in:
parent
8edc57ef40
commit
64400adf08
1 changed files with 3 additions and 1 deletions
|
@ -119,6 +119,9 @@ func flagRequiresArgumentCompletion(flag *pflag.Flag) string {
|
||||||
func subCommandPath(rootCmd *Command, cmd *Command) string {
|
func subCommandPath(rootCmd *Command, cmd *Command) string {
|
||||||
path := []string{}
|
path := []string{}
|
||||||
currentCmd := cmd
|
currentCmd := cmd
|
||||||
|
if rootCmd == cmd {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
for {
|
for {
|
||||||
path = append([]string{currentCmd.Name()}, path...)
|
path = append([]string{currentCmd.Name()}, path...)
|
||||||
if currentCmd.Parent() == rootCmd {
|
if currentCmd.Parent() == rootCmd {
|
||||||
|
@ -126,7 +129,6 @@ func subCommandPath(rootCmd *Command, cmd *Command) string {
|
||||||
}
|
}
|
||||||
currentCmd = currentCmd.Parent()
|
currentCmd = currentCmd.Parent()
|
||||||
}
|
}
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func rangeCommands(cmd *Command, callback func(subCmd *Command)) {
|
func rangeCommands(cmd *Command, callback func(subCmd *Command)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue