blob: b2b029335a217484647be73582609bd5f44f1641 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#!/usr/bin/env ruby
require 'rubygems'
require 'pp'
require 'appscript'
require 'mixlib/cli'
class MacDevStart
include Mixlib::CLI
include Appscript
SERVICES = %w{couchdb rabbitmq chef_solr chef_expander chef_server chef_webui}
option :environment,
:short => '-e ENV',
:long => '--environment ENV',
:default => 'test',
:description => 'Set the environment (test|dev), defaults to test'
def run
@srcdir = File.expand_path(File.dirname(__FILE__))
@base_cmd = case config[:environment]
when 'test'
"cd #{@srcdir} && rake dev:features:start:"
when 'dev'
"cd #{@srcdir} && rake dev:start:"
else
puts "--environment must be set to either 'test' or 'dev'"
puts @opt_parser
exit 1
end
STDOUT.puts "Starting services:"
pp SERVICES
start_services(SERVICES)
end
def create_tab
@window.activate
app("System Events").application_processes["Terminal.app"].keystroke("t", :using=>:command_down)
end
def terminal_app
@terminal_app ||= app("Terminal")
end
def create_term_window
terminal_app.windows.first.activate
app("System Events").application_processes["Terminal.app"].keystroke("n", :using=>:command_down)
@window = terminal_app.windows.first.get
end
def start_service_in_tab(service, tab)
# use xterm escape codes to set the tab title to the service running in the tab.
cmd = "unset PROMPT_COMMAND; echo -e \"\\033]0;#{service}\\007\"; #{@base_cmd}#{service}"
app('Terminal').do_script(cmd, :in => @window.tabs[tab].get)
end
def start_services(services)
create_term_window
tab_index = 1 # applescript indexes from 1 instead of 0
(services.size - 1).times { create_tab }
services.each do |service|
start_service_in_tab(service, tab_index)
tab_index += 1
end
end
end
if __FILE__ == $0
os = MacDevStart.new
os.parse_options
os.run
end
|