Class: Specjour::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/specjour/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dispatcher_optionObject



9
10
11
# File 'lib/specjour/cli.rb', line 9

def self.dispatcher_option
  method_option :alias, :aliases => "-a", :desc => "Project name advertised to listeners"
end

.rsync_port_optionObject



13
14
15
# File 'lib/specjour/cli.rb', line 13

def self.rsync_port_option
  method_option :rsync_port, :type => :numeric, :default => 23456, :desc => "Port to use for rsync daemon"
end

.start(original_args = ARGV, config = {}) ⇒ Object

allow specjour to be called with path arguments



18
19
20
21
22
23
24
25
# File 'lib/specjour/cli.rb', line 18

def self.start(original_args=ARGV, config={})
  Specjour.trap_interrupt
  real_tasks = all_tasks.keys | @map.keys
  unless real_tasks.include? original_args.first
    original_args.unshift default_task
  end
  super(original_args)
end

.worker_optionObject



5
6
7
# File 'lib/specjour/cli.rb', line 5

def self.worker_option
  method_option :workers, :aliases => "-w", :type => :numeric, :desc => "Number of concurent processes to run. Defaults to your system's available cores."
end

Instance Method Details

#dispatch(*paths) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/specjour/cli.rb', line 73

def dispatch(*paths)
  handle_logging
  handle_workers
  handle_dispatcher(paths)
  append_to_program_name "dispatch"
  Specjour::Dispatcher.new(args).start
end

#listenObject



38
39
40
41
42
43
44
# File 'lib/specjour/cli.rb', line 38

def listen
  handle_logging
  handle_workers
  args[:registered_projects] = args.delete(:projects) || [File.basename(Dir.pwd)]
  append_to_program_name "listen"
  Specjour::Manager.new(args).start
end

#loadObject



53
54
55
56
57
58
# File 'lib/specjour/cli.rb', line 53

def load
  handle_logging
  handle_workers
  append_to_program_name "load"
  Specjour::Loader.new(args).start
end

#prepare(path = Dir.pwd) ⇒ Object



89
90
91
92
93
94
95
96
97
98
# File 'lib/specjour/cli.rb', line 89

def prepare(path = Dir.pwd)
  handle_logging
  handle_workers
  args[:project_path] = File.expand_path(path)
  args[:project_alias] = args.delete(:alias)
  args[:test_paths] = []
  args[:worker_task] = 'prepare'
  append_to_program_name "prepare"
  Specjour::Dispatcher.new(args).start
end

#versionObject



102
103
104
# File 'lib/specjour/cli.rb', line 102

def version
  puts Specjour::VERSION
end