mirror of
https://github.com/spf13/cobra
synced 2025-05-05 12:57:22 +00:00
Merge b6c05a9e39
into f8e1ec56bd
This commit is contained in:
commit
4dbfe2ea7a
1 changed files with 15 additions and 15 deletions
30
command.go
30
command.go
|
@ -213,14 +213,14 @@ Aliases:
|
||||||
Examples:
|
Examples:
|
||||||
{{ .Example }}
|
{{ .Example }}
|
||||||
{{end}}{{ if .HasSubCommands}}
|
{{end}}{{ if .HasSubCommands}}
|
||||||
Available Commands: {{range .Commands}}{{if .Runnable}}
|
Available Commands: {{range .Commands}}{{if or .Runnable .HasSubCommands}}
|
||||||
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}
|
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{ if .HasLocalFlags}}Flags:
|
{{ if .HasLocalFlags}}Flags:
|
||||||
{{.LocalFlags.FlagUsages}}{{end}}
|
{{.LocalFlags.FlagUsages}}{{end}}
|
||||||
{{ if .HasAnyPersistentFlags}}Global Flags:
|
{{ if .HasAnyPersistentFlags}}Global Flags:
|
||||||
{{.AllPersistentFlags.FlagUsages}}{{end}}{{if .HasParent}}{{if and (gt .Commands 0) (gt .Parent.Commands 1) }}
|
{{.AllPersistentFlags.FlagUsages}}{{end}}{{if .HasParent}}{{if and (gt .Commands 0) (gt .Parent.Commands 1) }}
|
||||||
Additional help topics: {{if gt .Commands 0 }}{{range .Commands}}{{if not .Runnable}} {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if gt .Parent.Commands 1 }}{{range .Parent.Commands}}{{if .Runnable}}{{if not (eq .Name $cmd.Name) }}{{end}}
|
Additional help topics: {{if gt .Commands 0 }}{{range .Commands}}{{if not .Runnable}} {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if gt .Parent.Commands 1 }}{{range .Parent.Commands}}{{if or .Runnable .HasSubCommands}}{{if not (eq .Name $cmd.Name) }}{{end}}
|
||||||
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{end}}
|
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{end}}
|
||||||
{{end}}{{ if .HasSubCommands }}
|
{{end}}{{ if .HasSubCommands }}
|
||||||
Use "{{.Root.Name}} help [command]" for more information about a command.
|
Use "{{.Root.Name}} help [command]" for more information about a command.
|
||||||
|
@ -743,20 +743,20 @@ func (c *Command) InheritedFlags() *flag.FlagSet {
|
||||||
|
|
||||||
local := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
|
local := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
|
||||||
|
|
||||||
var rmerge func(x *Command)
|
var rmerge func(x *Command)
|
||||||
|
|
||||||
rmerge = func(x *Command) {
|
rmerge = func(x *Command) {
|
||||||
if x.HasPersistentFlags() {
|
if x.HasPersistentFlags() {
|
||||||
x.PersistentFlags().VisitAll(func(f *flag.Flag) {
|
x.PersistentFlags().VisitAll(func(f *flag.Flag) {
|
||||||
if local.Lookup(f.Name) == nil {
|
if local.Lookup(f.Name) == nil {
|
||||||
local.AddFlag(f)
|
local.AddFlag(f)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if x.HasParent() {
|
if x.HasParent() {
|
||||||
rmerge(x.parent)
|
rmerge(x.parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.HasParent() {
|
if c.HasParent() {
|
||||||
rmerge(c.parent)
|
rmerge(c.parent)
|
||||||
|
|
Loading…
Add table
Reference in a new issue