Changes from code review

This commit is contained in:
Naveen Gogineni
2022-10-11 09:18:57 -04:00
parent 59095aa762
commit a9d6b0d821
3 changed files with 31 additions and 26 deletions

View File

@@ -106,32 +106,11 @@ func (cmd *Command) Command(name string) *Command {
return nil
}
func newRootCommand(a *App) *Command {
return &Command{
HelpName: a.HelpName,
Subcommands: a.Commands,
flagCategories: a.flagCategories,
Flags: a.Flags,
Name: a.Name,
Action: a.Action,
UseShortOptionHandling: a.UseShortOptionHandling,
Before: a.Before,
After: a.After,
HideHelp: a.HideHelp,
HideHelpCommand: a.HideHelpCommand,
OnUsageError: a.OnUsageError,
CustomHelpTemplate: a.CustomAppHelpTemplate,
Usage: a.Usage,
UsageText: a.UsageText,
Description: a.Description,
ArgsUsage: a.ArgsUsage,
BashComplete: a.BashComplete,
categories: a.categories,
isRoot: true,
}
}
func (c *Command) setup(ctx *Context) {
if c.HelpName == "" {
c.HelpName = fmt.Sprintf("%s %s", ctx.parentContext.Command.HelpName, c.Name)
}
if c.Command(helpCommand.Name) == nil && !c.HideHelp {
if !c.HideHelpCommand {
c.Subcommands = append(c.Subcommands, helpCommand)