Skip to content

Commit

Permalink
feat(cmd): override help for all commands
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
  • Loading branch information
leodido authored and fntlnz committed Feb 7, 2019
1 parent 350fc53 commit 1ee9a77
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ type RunOptions struct {
namespace string
explicitNamespace bool

// Local to this command
// Flags local to this command
container string
eval string
program string
resourceArg string
attach bool
isPod bool
podUID string
serviceAccount string

nodeName string
resourceArg string
attach bool
isPod bool
podUID string
nodeName string

clientConfig *rest.Config
}
Expand Down
13 changes: 13 additions & 0 deletions pkg/cmd/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,18 @@ func NewTraceCommand(streams genericclioptions.IOStreams) *cobra.Command {
cmd.AddCommand(NewVersionCommand(streams))
cmd.AddCommand(NewLogCommand(f, streams))

// Override help on all the commands tree
walk(cmd, func(c *cobra.Command) {
c.Flags().BoolP("help", "h", false, fmt.Sprintf("Help for the %s command", c.Name()))
})

return cmd
}

// walk calls f for c and all of its children.
func walk(c *cobra.Command, f func(*cobra.Command)) {
f(c)
for _, c := range c.Commands() {
walk(c, f)
}
}

0 comments on commit 1ee9a77

Please sign in to comment.