lib/doit.rb in doit-0.2.8 vs lib/doit.rb in doit-0.3.0

- old
+ new

@@ -1,27 +1,28 @@ require 'my' require 'run' require 'import' require 'what' -class Doit +Doit = Object.new +class << Doit - def self.start(options) + def start(options) @options = options list if options[:list] script = ARGV.shift str = ARGV.map { |x| "\"#{x}\"" }.join(' ') @argv = str.empty? ? '' : "set #{str}\n" execute(script) if script end - def self.options + def options @options || {} end - def self.list + def list hsh = Import.list hsh.sort.each { |abb, long| puts "#{abb}\t- #{long}" next unless options[:verbose] lines = `grep -i 'usage\\|summary' #{long} | grep '^#'`.split("\n") @@ -31,28 +32,32 @@ puts "\t #{line}" } } end - def self.execute(name) + def execute(name) Import.init(name) unless Import.script puts "doit: script '#{name}' not found" return end What.init(Import.script, Import.config) - where_loop + What.where.each { |w| + puts "doit #{name} -r #{w}" + } if options[:each] + + where_loop unless options[:each] end private - def self.where_loop + def where_loop What.where.each { |w| matrix_loop(w) } end - def self.matrix_loop(w) + def matrix_loop(w) What.matrix.each { |mm| prefix = mm.empty? ? '' : "#{What.to_env(mm)}\n" What.env.each { |en| prefix2 = en.empty? ? '' : "#{en}\n"