Skip to content

Commit

Permalink
Revert to the old behavior of argsHaveOption.
Browse files Browse the repository at this point in the history
 The first time an argument is found is the
one being used.
  • Loading branch information
Arkaeriit committed Sep 18, 2022
1 parent 05f3c8c commit 1417213
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions rem.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,21 @@ func promptBool(promptStr string) (yes bool) {
return true
}

// Try to find the position of the given argument, the posistioon of the first
// instance is returned.
func argsHaveOption(long string, short string) (hasOption bool, foundAt int) {
hasOption, foundAt = argsHaveOptionExplicit("-" + short)
if hasOption {
return true, foundAt
hasOptionShort, foundAtShort := argsHaveOptionExplicit("-" + short)
hasOptionLong, foundAtLong := argsHaveOptionExplicit("--" + long)
if hasOptionShort && hasOptionLong {
if foundAtLong < foundAtShort {
return true, foundAtLong
}
return true, foundAtShort
}
if hasOptionShort {
return true, foundAtShort
}
return argsHaveOptionLong(long)
return hasOptionLong, foundAtLong
}

func argsHaveOptionLong(long string) (hasOption bool, foundAt int) {
Expand Down

0 comments on commit 1417213

Please sign in to comment.