#!/usr/bin/env ruby require 'rbbt/workflow' require 'rbbt-util' require 'rbbt-util' require 'rbbt/util/simpleopt' $0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands options = SOPT.setup < -h--help Help -a--all Print all info entries -r--recursive Print recursive input values EOF SOPT.usage if options[:help] file = ARGV.shift all = options.delete :all recursive = options.delete :recursive def get_step(file) file = file.sub(/\.(info|files)/,'') Step.new file end def status_msg(status) color = case status when :error, :aborted, :missing :red when :streaming :yellow when :done :green else nil end Log.color(color, status) end def pid_msg(pid, done = false) color = if pid and (done or Misc.pid_exists? pid) :green else :red end if pid.nil? "" else Log.color(color, pid) end end step = get_step file info = step.info dependencies = info[:dependencies] inputs = info[:inputs] status = info[:status] time = info[:time_elapsed] total_time = info[:total_time_elapsed] messages = info[:messages] backtrace = info[:backtrace] pid = info[:pid] exception = info[:exception] rest = info.keys - [:inputs, :dependencies, :status, :time_elapsed, :messages, :backtrace, :exception, :pid] puts Log.color(:magenta, "File") << ": " << step.path puts Log.color(:magenta, "Status") << ": " << status_msg(status) puts Log.color(:magenta, "Pid") << ": " << pid_msg(pid, status.to_s == "done") puts Log.color(:magenta, "Time") << ": " << time.to_i.to_s << " sec." if time puts Log.color(:magenta, "Total time") << ": " << total_time.to_i.to_s << " sec." if time if inputs and inputs.any? puts Log.color(:magenta, "Inputs") inputs.each do |input,value| case value when nil puts " " << Misc.format_definition_list_item(input, 'nil', 80, 20, :blue) when Array puts " " << Misc.format_definition_list_item(input, (value.length > 6 ? value[0..5]*"\n" << "\n" << "..." : value * "\n" ), 80, 20, :blue) when TrueClass, FalseClass puts " " << Misc.format_definition_list_item(input, value.to_s, 80, 20, :blue) else text = value.to_s.split("\n")[0..5].compact * "\n\n" puts " " << Misc.format_definition_list_item(input, text, 80, 20, :blue) end end end if dependencies and dependencies.any? puts Log.color(:magenta, "Dependencies") << ": " dependencies.each do |name,task,file| puts " " << file end end if messages and messages.any? puts Log.color(:magenta, "Messages") << ": " messages.each do |msg| puts " " << msg end end if status == :error puts Log.color(:magenta, "Backtrace") << ": " puts Log.color_stack backtrace end if all puts Log.color(:magenta, "Other entries") << ": " rest.each do |key| puts Misc.format_definition_list_item(key, info[key].to_s) end end if recursive puts Log.color(:magenta, "Recursive inputs") << ": " inputs = step.info[:inputs] deps = step.info[:dependencies].collect{|v| get_step v.last } while deps.any? do dep = deps.shift inputs = inputs.merge(dep.info[:inputs] || {}) deps.concat (dep.info[:dependencies] || []).collect{|v| get_step v.last } end inputs.each do |input,value| case value when nil puts " " << Misc.format_definition_list_item(input, 'nil', 80, 20, :blue) when Array puts " " << Misc.format_definition_list_item(input, (value.length > 6 ? value[0..5]*"\n" << "\n" << "..." : value * "\n" ), 80, 20, :blue) when TrueClass, FalseClass puts " " << Misc.format_definition_list_item(input, value.to_s, 80, 20, :blue) else text = value.to_s.split("\n")[0..5].compact * "\n\n" puts " " << Misc.format_definition_list_item(input, text, 80, 20, :blue) end end end