Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sandro committed Jun 24, 2010
1 parent edc4535 commit 7b9b1ec
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 37 deletions.
75 changes: 38 additions & 37 deletions bin/specjour
@@ -1,51 +1,52 @@
#!/usr/bin/env ruby
require 'optparse'
require 'specjour'

options = {:batch_size => 1}
Specjour::CLI.start

optparse = OptionParser.new do |opts|
opts.banner = "Usage: specjour [options]"
# options = {:batch_size => 1}

opts.on('-w', '--workers WORKERS', Numeric, "Number of WORKERS to spin up, defaults to available cores") do |n|
options[:worker_size] = n
end
# optparse = OptionParser.new do |opts|
# opts.banner = "Usage: specjour [options]"

opts.on('-b', '--batch-size [SIZE]', Integer, "Number of specs to run before reporting back to the dispatcher, defaults to #{options[:batch_size]}") do |n|
options[:batch_size] = n
end
# opts.on('-w', '--workers WORKERS', Numeric, "Number of WORKERS to spin up, defaults to available cores") do |n|
# options[:worker_size] = n
# end

opts.on('-p', '--projects PROJECTS', Array, "Only run specs for these comma delimited project names, i.e. workbeast,taigan") do |project_names|
options[:registered_projects] = project_names
end
# opts.on('-b', '--batch-size [SIZE]', Integer, "Number of specs to run before reporting back to the dispatcher, defaults to #{options[:batch_size]}") do |n|
# options[:batch_size] = n
# end

opts.on('--do-work OPTIONS', Array, 'INTERNAL USE ONLY') do |args|
options[:worker_args] = args[0], args[1], args[2]
end
# opts.on('-p', '--projects PROJECTS', Array, "Only run specs for these comma delimited project names, i.e. workbeast,taigan") do |project_names|
# options[:registered_projects] = project_names
# end

opts.on('--log', TrueClass, 'print debug messages to stdout') do |val|
Specjour.new_logger Logger::DEBUG
end
# opts.on('--do-work OPTIONS', Array, 'INTERNAL USE ONLY') do |args|
# options[:worker_args] = args[0], args[1], args[2]
# end

opts.on_tail('-v', '--version', 'Show the version of specjour') do
abort Specjour::VERSION
end
# opts.on('--log', TrueClass, 'print debug messages to stdout') do |val|
# Specjour.new_logger Logger::DEBUG
# end

opts.on_tail("-h", "--help", "Show this message") do
summary = opts.to_a
summary.first << "\n"
abort summary.reject {|s| s =~ /INTERNAL/}.join
end
end
# opts.on_tail('-v', '--version', 'Show the version of specjour') do
# abort Specjour::VERSION
# end

optparse.parse!
# opts.on_tail("-h", "--help", "Show this message") do
# summary = opts.to_a
# summary.first << "\n"
# abort summary.reject {|s| s =~ /INTERNAL/}.join
# end
# end

abort(%(ERROR: I don't understand the following flags: "#{ARGV.join(', ')}")) if ARGV.any?
# optparse.parse!

if options[:worker_args]
options[:worker_args] << options[:batch_size]
Specjour::Worker.new(*options[:worker_args]).run
else
options[:worker_size] ||= Specjour::CPU.cores
Specjour::Manager.new(options).start
end
# abort(%(ERROR: I don't understand the following flags: "#{ARGV.join(', ')}")) if ARGV.any?

# if options[:worker_args]
# options[:worker_args] << options[:batch_size]
# Specjour::Worker.new(*options[:worker_args]).run
# else
# options[:worker_size] ||= Specjour::CPU.cores
# Specjour::Manager.new(options).start
# end
1 change: 1 addition & 0 deletions lib/specjour.rb
Expand Up @@ -9,6 +9,7 @@
autoload :Socket, 'socket'

module Specjour
autoload :CLI, 'specjour/cli'
autoload :CPU, 'specjour/cpu'
autoload :Connection, 'specjour/connection'
autoload :Dispatcher, 'specjour/dispatcher'
Expand Down
36 changes: 36 additions & 0 deletions lib/specjour/cli.rb
@@ -0,0 +1,36 @@
module Specjour
require 'thor'
class CLI < Thor
default_task :dispatch

desc "manage", "Advertise availability to run specs"
method_option :workers, :type => :numeric, :desc => "Number of concurent processes to run"
method_option :projects, :type => :array, :desc => "Projects supported by this manager"
def manage(number=1)
p number
p options
end

desc "dispatch [PROJECT_PATH]", "Run specs in this project"
method_option :workers, :type => :numeric, :desc => "Number of concurent processes to run"
method_option :alias, :desc => "Project name advertised to listeners"
def dispatch(path = Dir.pwd)
p path
p options
end

desc "version", "Show the version of specjour"
def version
puts Specjour::VERSION
end

desc "work", "INTERNAL USE ONLY"
def work
puts 'working'
end

def self.printable_tasks
super.reject{|t| t.last =~ /INTERNAL USE/ }
end
end
end

0 comments on commit 7b9b1ec

Please sign in to comment.