lib/command.rb in dev_commands-0.0.23 vs lib/command.rb in dev_commands-0.0.24

- old
+ new

@@ -27,11 +27,11 @@ } end end def execute - puts "#{self[:input]}" + puts "#{self[:input]}" if(!self.has_key?(:quiet) || self[:quiet]) pwd=Dir.pwd Dir.chdir(self[:directory]) if(self.has_key?(:directory) && File.exists?(self[:directory])) self[:directory] = pwd if(self[:directory].length==0) self[:machine] = Command.machine @@ -51,12 +51,12 @@ self[:elapsed] = timer.elapsed_str self[:end_time] = Time.now else begin - self[:output],self[:error],status= Open3.capture3(self[:input]) - self[:exit_code]=status.to_i + self[:output],self[:error],status= Open3.capture3(self[:input]) + self[:exit_code]=status.to_i self[:elapsed] = timer.elapsed_str self[:end_time] = Time.now rescue Exception => e self[:elapsed] = timer.elapsed_str self[:end_time] = Time.now @@ -66,16 +66,18 @@ end Dir.chdir(pwd) if pwd != Dir.pwd if(self[:exit_code] != 0) - puts ' ' - puts "exit_code=#{self[:exit_code]}" - puts ' ' - puts self[:output] - puts self[:error] - puts ' ' + if(!self.has_key?(:quiet) || self[:quiet]) + puts ' ' + puts "exit_code=#{self[:exit_code]}" + puts ' ' + puts self[:output] + puts self[:error] + puts ' ' + end if(!self.has_key?(:ignore_failure) || !self[:ignore_failure]) raise "#{self[:input]} failed" end #unless (self.has_key?(:ignore_failure) && self[:ignore_failure]==true) end end @@ -95,16 +97,18 @@ end def self.exit_code command cmd = Command.new(command) cmd[:ignore_failure]=true + cmd[:quiet]=true cmd.execute cmd[:exit_code] end def self.output command cmd = Command.new(command) cmd[:ignore_failure]=true + cmd[:quiet]=true cmd.execute cmd[:output] end def to_html \ No newline at end of file