diff --git a/bin/yamg b/bin/yamg index 209805c..d69e366 100755 --- a/bin/yamg +++ b/bin/yamg @@ -1,4 +1,4 @@ #!/usr/bin/env ruby $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'yamg' -YAMG::CLI.new(ARGV) +YAMG::CLI.new(ARGV).work! diff --git a/lib/yamg/cli.rb b/lib/yamg/cli.rb index e0cff24..076c5dd 100644 --- a/lib/yamg/cli.rb +++ b/lib/yamg/cli.rb @@ -11,8 +11,6 @@ def initialize(argv) return YAMG.init if argv.join =~ /init/ YAMG.load_config # (argv) @works = YAMG.config['compile'] - compile - screenshot end def setup_for(opts) @@ -58,15 +56,22 @@ def compile_work(scope, opts) end def compile(scope = nil) - time = Time.now works.select! { |w| w =~ scope } if scope works.each { |out, opts| compile_work(out, opts) } works.select! { |w| w =~ scope } if scope puts Rainbow("Working on #{works.keys.join(', ')}").yellow + end + def screenshot YAMG.config['screenshots'].each do |ss| Thread.new { Screenshot.new(ss).work('./media') } end + end + + def work! + time = Time.now + compile + screenshot puts Rainbow(Thread.list.size.to_s + ' jobs').black Thread.list.reject { |t| t == Thread.current }.each(&:join) puts Rainbow('-' * 59).black