Skip to content

Commit

Permalink
Merge pull request #2851 from rolandwalker/system_command_followups
Browse files Browse the repository at this point in the history
System command followups
  • Loading branch information
rolandwalker committed Feb 11, 2014
2 parents d097094 + 5548bc4 commit 0700813
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/cask/system_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ def self.run(executable, options={})
end
end

def self.run!(command, options)
def self.run!(command, options={})
run(command, options.merge(:must_succeed => true))
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', '--')
end
if ! options[:args].empty?
if options.key?(:args) and
! options[:args].empty?
command.concat options[:args]
end
command
Expand Down
10 changes: 10 additions & 0 deletions lib/cask/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ def magenta; color 35; end
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
Expand Down

0 comments on commit 0700813

Please sign in to comment.