diff --git a/cli.go b/cli.go index 584205d..5fdc40a 100644 --- a/cli.go +++ b/cli.go @@ -169,7 +169,8 @@ func (this *Cli) ParseOrExit (args []string) *Cli { // was found, it returns true. If it was not found, it returns nil, false. func (this *Cli) ShortFlag (short rune) (*Flag, bool) { if short == 0 { return nil, false } - for _, flag := range this.Flags { + for index := len(this.Flags) - 1; index >= 0; index -- { + flag := this.Flags[index] if flag.Short == short { return flag, true } } return nil, false @@ -179,7 +180,8 @@ func (this *Cli) ShortFlag (short rune) (*Flag, bool) { // was found, it returns true. If it was not found, it returns nil, false. func (this *Cli) LongFlag (long string) (*Flag, bool) { if long == "" { return nil, false } - for _, flag := range this.Flags { + for index := len(this.Flags) - 1; index >= 0; index -- { + flag := this.Flags[index] if flag.Long == long { return flag, true } } return nil, false