mirror of
https://github.com/spf13/cobra
synced 2025-05-06 05:17:21 +00:00
Disable flags in UseLine
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
parent
7b2c5ac9fc
commit
5bc62ceeec
1 changed files with 7 additions and 0 deletions
|
@ -118,6 +118,10 @@ type Command struct {
|
|||
// will be printed by generating docs for this command.
|
||||
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
|
||||
// that go along with 'unknown command' messages.
|
||||
DisableSuggestions bool
|
||||
|
@ -996,6 +1000,9 @@ func (c *Command) UseLine() string {
|
|||
} else {
|
||||
useline = c.Use
|
||||
}
|
||||
if c.DisableFlagsInUseLine {
|
||||
return useline
|
||||
}
|
||||
if c.HasAvailableFlags() && !strings.Contains(useline, "[flags]") {
|
||||
useline += " [flags]"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue