Simplify implementation of ARGV.flag? and ARGV.switch?
This commit is contained in:
parent
54348f55d8
commit
db04b04135
@ -135,9 +135,7 @@ module HomebrewArgvExtension
|
|||||||
end
|
end
|
||||||
|
|
||||||
def flag? flag
|
def flag? flag
|
||||||
options_only.any? do |arg|
|
options_only.include?(flag) || switch?(flag[2, 1])
|
||||||
arg == flag || arg[1, 1] != "-" && arg.include?(flag[2, 1])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def force_bottle?
|
def force_bottle?
|
||||||
@ -145,11 +143,9 @@ module HomebrewArgvExtension
|
|||||||
end
|
end
|
||||||
|
|
||||||
# eg. `foo -ns -i --bar` has three switches, n, s and i
|
# eg. `foo -ns -i --bar` has three switches, n, s and i
|
||||||
def switch? switch_character
|
def switch? char
|
||||||
return false if switch_character.length > 1
|
return false if char.length > 1
|
||||||
options_only.any? do |arg|
|
options_only.any? { |arg| arg[1, 1] != "-" && arg.include?(char) }
|
||||||
arg[1, 1] != "-" && arg.include?(switch_character)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def usage
|
def usage
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user