diff --git a/app.go b/app.go index 9e540b2..659ef47 100644 --- a/app.go +++ b/app.go @@ -29,7 +29,7 @@ func NewApp() *App { func (a *App) Run(arguments []string) { // parse flags - set := flagSet(a.Flags) + set := flagSet(a.Name, a.Flags) set.Parse(arguments[1:]) // append help to commands diff --git a/command.go b/command.go index d8e2011..671c218 100644 --- a/command.go +++ b/command.go @@ -9,12 +9,12 @@ type Command struct { Flags []Flag } -func (command Command) Run(c *Context) { - set := flagSet(command.Flags) - set.Parse(c.Args()[1:]) - command.Action(NewContext(c.App, set, c.globalSet)) +func (c Command) Run(ctx *Context) { + set := flagSet(c.Name, c.Flags) + set.Parse(ctx.Args()[1:]) + c.Action(NewContext(ctx.App, set, ctx.globalSet)) } -func (command Command) HasName(name string) bool { - return command.Name == name || command.ShortName == name +func (c Command) HasName(name string) bool { + return c.Name == name || c.ShortName == name } diff --git a/flag.go b/flag.go index 4601236..d6ee6e6 100644 --- a/flag.go +++ b/flag.go @@ -8,8 +8,8 @@ type Flag interface { Apply(*flag.FlagSet) } -func flagSet(flags []Flag) *flag.FlagSet { - set := flag.NewFlagSet("cli", flag.ExitOnError) +func flagSet(name string, flags []Flag) *flag.FlagSet { + set := flag.NewFlagSet(name, flag.ExitOnError) for _, f := range flags { f.Apply(set) }