JMS #4: Command.HasName

This commit is contained in:
Jeremy Saenz 2013-07-18 19:30:18 -07:00
parent 4495e2e996
commit c15c42a7a8
2 changed files with 5 additions and 1 deletions

2
cli.go
View File

@ -29,7 +29,7 @@ func Run(arguments []string) {
if len(args) > 0 {
name := args[0]
for _, c := range append(Commands, HelpCommand) {
if c.Name == name || c.ShortName == name {
if c.HasName(name) {
c.Run(context)
return
}

View File

@ -14,3 +14,7 @@ func (command Command) Run(c *Context) {
set.Parse(c.Args()[1:])
command.Action(NewContext(set, c.globalSet))
}
func (command Command) HasName(name string) bool {
return command.Name == name || command.ShortName == name
}