test valid keys in _process_options
add monkeypatch on Hash in utils.rb for `assert_valid_keys` method
This commit is contained in:
parent
545fc276dc
commit
5548bc4756
|
@ -33,6 +33,7 @@ class Cask::SystemCommand
|
|||
end
|
||||
|
||||
def self._process_options(executable, options)
|
||||
options.assert_valid_keys :input, :print, :stderr, :args, :must_succeed, :sudo, :plist
|
||||
command = [executable]
|
||||
if options[:sudo]
|
||||
command.unshift('/usr/bin/sudo', '-E', '--')
|
||||
|
|
|
@ -10,6 +10,16 @@ class Tty
|
|||
end
|
||||
end
|
||||
|
||||
# monkeypatch Hash
|
||||
class Hash
|
||||
def assert_valid_keys(*valid_keys)
|
||||
unknown_keys = self.keys - valid_keys
|
||||
unless unknown_keys.empty?
|
||||
raise "Unknown keys: #{unknown_keys.join(", :")}. Running `brew update; brew upgrade brew-cask` will likely fix it."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def odebug title, *sput
|
||||
if Cask.respond_to?(:debug) and Cask.debug
|
||||
width = Tty.width * 4 - 6
|
||||
|
|
Loading…
Reference in New Issue