lib/octopolo/cli.rb in octopolo-0.3.5 vs lib/octopolo/cli.rb in octopolo-0.3.6

- old
+ new

@@ -6,10 +6,11 @@ class CLI # Public: Perform the given shell command. # # command - A String containing the command to perform. # say_command - A Boolean determining whether to display the performed command to the screen. (default: true) + # ignore_non_zero - Ignore exception for non-zero exit status of command. # # Examples # # CLI.perform "git pull", false # git pull @@ -18,16 +19,16 @@ # # CLI.perform "git pull", false # # => "Already up-to-date." # # Returns the output of the command as a String. - def self.perform(command, say_command = true) + def self.perform(command, say_command = true, ignore_non_zero=false) # display the command say command if say_command # and then perform it if Open3.respond_to?(:capture3) output, error, status = Open3.capture3(command) - raise "command=#{command}; exit_status=#{status.exitstatus}; stderr=#{error}" unless status.success? + raise "command=#{command}; exit_status=#{status.exitstatus}; stderr=#{error}" unless status.success? || ignore_non_zero else # Only necessary as long as we use 1.8.7, which doesn't have Open3.capture3 output = `#{command}` end