diff options
author | Adam Jacob <adam@opscode.com> | 2009-09-26 11:33:00 -0700 |
---|---|---|
committer | Adam Jacob <adam@opscode.com> | 2009-09-26 11:33:00 -0700 |
commit | 3014147e50475bb7d432439654a20cfb4110b18e (patch) | |
tree | 6b933a0d01f18151e79e1c10d89da09a76a58df4 /scripts | |
parent | 9cd5aff3f25e4370e1e5586742a17698dcf1f8de (diff) | |
download | chef-3014147e50475bb7d432439654a20cfb4110b18e.tar.gz |
Adding mac-dev-start script, that spawns terminals for you on mac
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/mac-dev-start | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/scripts/mac-dev-start b/scripts/mac-dev-start new file mode 100755 index 0000000000..ceef75fd3d --- /dev/null +++ b/scripts/mac-dev-start @@ -0,0 +1,54 @@ +#!/usr/bin/env ruby + +require 'rubygems' +require 'appscript' + +include Appscript + +SRCDIR = File.expand_path(File.join(File.dirname(__FILE__), "..")) +DELAY = 1 +BASE_CMD = case ARGV[0] + when "features" + "cd #{SRCDIR} && sudo rake dev:features:start:" + when "dev" + "cd #{SRCDIR} && sudo rake dev:start:" + else + "cd #{SRCDIR} && sudo rake dev:start:" + end +SERVICES = ["couchdb","rabbitmq","chef_solr","chef_solr_indexer","chef_server"] + +def auth_up + system("sudo echo") +end + +def create_tab + app("System Events").application_processes["Terminal.app"].keystroke("t", :using=>:command_down) +end + +def activate_terminal + app("/Applications/Utilities/Terminal.app").windows.first.activate + app("System Events").application_processes["Terminal.app"].keystroke("n", :using=>:command_down) + app('Terminal') +end + +def start_service_in_last_tab(window,service) + app('Terminal').do_script(BASE_CMD+service, :in => window.tabs.last.get) + sleep DELAY +end + +def start_services + auth_up + term = activate_terminal + window = term.windows.first.get + + SERVICES.each do |service| + create_tab + start_service_in_last_tab(window,service) + end +end + + +if __FILE__ == $0 + start_services +end + |