forked from mirror/cobra
Disable flags in UseLine (#552)
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
parent
d6948b782c
commit
34ceca591b
|
@ -118,6 +118,10 @@ type Command struct {
|
||||||
// will be printed by generating docs for this command.
|
// will be printed by generating docs for this command.
|
||||||
DisableAutoGenTag bool
|
DisableAutoGenTag bool
|
||||||
|
|
||||||
|
// DisableFlagsInUseLine will disable the addition of [flags] to the usage
|
||||||
|
// line of a command when printing help or generating docs
|
||||||
|
DisableFlagsInUseLine bool
|
||||||
|
|
||||||
// DisableSuggestions disables the suggestions based on Levenshtein distance
|
// DisableSuggestions disables the suggestions based on Levenshtein distance
|
||||||
// that go along with 'unknown command' messages.
|
// that go along with 'unknown command' messages.
|
||||||
DisableSuggestions bool
|
DisableSuggestions bool
|
||||||
|
@ -994,6 +998,9 @@ func (c *Command) UseLine() string {
|
||||||
} else {
|
} else {
|
||||||
useline = c.Use
|
useline = c.Use
|
||||||
}
|
}
|
||||||
|
if c.DisableFlagsInUseLine {
|
||||||
|
return useline
|
||||||
|
}
|
||||||
if c.HasAvailableFlags() && !strings.Contains(useline, "[flags]") {
|
if c.HasAvailableFlags() && !strings.Contains(useline, "[flags]") {
|
||||||
useline += " [flags]"
|
useline += " [flags]"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue