Align shared debug help and completion
This commit is contained in:
@@ -252,7 +252,7 @@ func displayCommandPath(rootName string, path []string) string {
|
||||
return strings.Join(parts, " ")
|
||||
}
|
||||
|
||||
// UsageLine returns Cobra's usage line for an exact path on this session.
|
||||
// UsageLine returns usage for an exact path on this session.
|
||||
func (session *Session) UsageLine(path []string) (string, *commandmeta.Failure) {
|
||||
if session == nil || session.root == nil {
|
||||
return "", &commandmeta.Failure{Message: "command tree is nil"}
|
||||
@@ -267,6 +267,22 @@ func (session *Session) UsageLine(path []string) (string, *commandmeta.Failure)
|
||||
if selected.HasSubCommands() {
|
||||
line += " [command]"
|
||||
}
|
||||
for _, flag := range declaration.Flags {
|
||||
if flag.Name != "debug" || !flag.Boolean {
|
||||
continue
|
||||
}
|
||||
for _, effective := range commandmeta.EffectiveFlags(declaration.Flags, declaration.CoreFlags) {
|
||||
if effective.Name == "debug" {
|
||||
spelling := "--debug"
|
||||
if effective.Short != "" {
|
||||
spelling = "-" + effective.Short + ", " + spelling
|
||||
}
|
||||
line += "\n " + spelling + " " + flagUsage(effective)
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
return line, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user