mirror of
https://github.com/spf13/cobra
synced 2025-05-06 05:17:21 +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 {
|
||||
path := []string{}
|
||||
currentCmd := cmd
|
||||
if rootCmd == cmd {
|
||||
return ""
|
||||
}
|
||||
for {
|
||||
path = append([]string{currentCmd.Name()}, path...)
|
||||
if currentCmd.Parent() == rootCmd {
|
||||
|
@ -126,7 +129,6 @@ func subCommandPath(rootCmd *Command, cmd *Command) string {
|
|||
}
|
||||
currentCmd = currentCmd.Parent()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func rangeCommands(cmd *Command, callback func(subCmd *Command)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue