mirror of
https://github.com/spf13/cobra
synced 2024-11-24 14:47:12 +00:00
Adding debug flags method to a command & commander
This commit is contained in:
parent
c568b575aa
commit
ccbe1b2359
1 changed files with 15 additions and 0 deletions
15
cobra.go
15
cobra.go
|
@ -179,6 +179,21 @@ func (c *Command) Usage(depth ...int) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Command) DebugFlags() {
|
||||||
|
fmt.Println("called on", c.Name())
|
||||||
|
if c.HasSubCommands() {
|
||||||
|
for _, x := range c.commands {
|
||||||
|
fmt.Println(x.Name())
|
||||||
|
x.flags.VisitAll(func(f *flag.Flag) { fmt.Println(" l:"+f.Name, f.Shorthand, f.DefValue, ":", f.Value) })
|
||||||
|
x.pflags.VisitAll(func(f *flag.Flag) { fmt.Println(" p:"+f.Name, f.Shorthand, f.DefValue, ":", f.Value) })
|
||||||
|
fmt.Println(x.flagErrorBuf)
|
||||||
|
if x.HasSubCommands() {
|
||||||
|
x.DebugFlags()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Usage prints the usage details to the standard output.
|
// Usage prints the usage details to the standard output.
|
||||||
func (c *Command) PrintUsage() {
|
func (c *Command) PrintUsage() {
|
||||||
if c.Runnable() {
|
if c.Runnable() {
|
||||||
|
|
Loading…
Reference in a new issue