Add HideHelp flag in App and Command

This commit is contained in:
Audrius Butkevicius
2014-07-13 14:16:30 +01:00
parent d38a3b82a6
commit 4a645835f0
2 changed files with 16 additions and 9 deletions

View File

@@ -29,6 +29,8 @@ type Command struct {
Flags []Flag
// Treat all flags as normal arguments if true
SkipFlagParsing bool
// Boolean to hide built-in help command
HideHelp bool
}
// Invokes the command given the context, parses ctx.Args() to generate command-specific flags
@@ -38,11 +40,13 @@ func (c Command) Run(ctx *Context) error {
return c.startApp(ctx)
}
// append help to flags
c.Flags = append(
c.Flags,
HelpFlag,
)
if !c.HideHelp {
// append help to flags
c.Flags = append(
c.Flags,
HelpFlag,
)
}
if ctx.App.EnableBashCompletion {
c.Flags = append(c.Flags, BashCompletionFlag)
@@ -117,6 +121,7 @@ func (c Command) startApp(ctx *Context) error {
// set the flags and commands
app.Commands = c.Subcommands
app.Flags = c.Flags
app.HideHelp = c.HideHelp
// bash completion
app.EnableBashCompletion = ctx.App.EnableBashCompletion