lib/capstrap/cli.rb in capstrap-0.2.1 vs lib/capstrap/cli.rb in capstrap-0.2.2

- old
+ new

@@ -4,15 +4,20 @@ def initialize(*) super end default_task :help + + desc "version", "Version of capstrap" + def version + puts "capstrap v#{Capstrap::VERSION}" + end desc "ruby HOST", "Install an RVM ruby on remote SSH host HOST" - method_option "ruby", :type => :string, :banner => + method_option "ruby", :type => :string, :desc => "Version of ruby to install.", :default => "ree-1.8.7" - method_option "default", :type => :boolean, :banner => + method_option "default", :type => :boolean, :desc => "Set this ruby to be RVM default." def ruby(ssh_host) @ssh_host = ssh_host abort ">> HOST must be set" unless @ssh_host @@ -23,11 +28,11 @@ config.find_and_execute_task "rvm:default:#{options[:ruby]}" end end desc "chef HOST", "Install chef gem on remote SSH host HOST" - method_option "ruby", :type => :string, :banner => + method_option "ruby", :type => :string, :desc => "Version of ruby to install.", :default => "ree-1.8.7" def chef(ssh_host) @ssh_host = ssh_host abort ">> HOST must be set" unless @ssh_host @@ -36,22 +41,36 @@ invoke :ruby, [ssh_host], :ruby => options[:ruby], :default => true config.find_and_execute_task "chef:install:lib" end desc "solo HOST", "Install chef cookbooks & config on remote SSH host HOST" - method_option "ruby", :type => :string, :banner => - "Version of ruby to install.", :default => "ree-1.8.7" - method_option "cookbooks-repo", :type => :string, :banner => - "Chef cookbooks git repository URL." + method_option "ruby", :type => :string, + :desc => "Version of ruby to install.", + :default => "ree-1.8.7", + :aliases => "-r" + method_option "cookbooks-repo", :type => :string, + :desc => "Chef cookbooks git repository URL.", + :aliases => "-c" method_option "cookbooks-path", :type => :string, - :banner => "Install path to chef cookbooks git repository.", - :default => "/var/chef-solo" - method_option "config-repo", :type => :string, :banner => - "Chef configuration git repository URL." + :desc => "Install path to chef cookbooks git repository.", + :default => "/var/chef-solo", + :aliases => "-p" + method_option "cookbooks-rake-update", :type => :boolean, :desc => + "Run rake update vs. git submodule init/update when updating cookbooks repo", + :default => false, + :aliases => "-u" + method_option "config-repo", :type => :string, + :desc => "Chef configuration git repository URL.", + :aliases => "-C" method_option "config-path", :type => :string, - :banner => "Install path to chef configuration git repository.", - :default => "/etc/chef" + :desc => "Install path to chef configuration git repository.", + :default => "/etc/chef", + :aliases => "-P" + method_option "config-rake-update", :type => :boolean, :desc => + "Run rake update vs. git submodule init/update when updating config repo", + :default => false, + :aliases => "-U" def solo(ssh_host) @ssh_host = ssh_host abort ">> HOST must be set" unless @ssh_host setup_config options @@ -67,22 +86,36 @@ config.find_and_execute_task "chef:install:cookbooks" config.find_and_execute_task "chef:install:config" end desc "execute HOST", "Executes chef solo config on remote SSH host HOST" - method_option "ruby", :type => :string, :banner => - "Version of ruby to install.", :default => "ree-1.8.7" - method_option "cookbooks-repo", :type => :string, :banner => - "Chef cookbooks git repository URL." + method_option "ruby", :type => :string, + :desc => "Version of ruby to install.", + :default => "ree-1.8.7", + :aliases => "-r" + method_option "cookbooks-repo", :type => :string, + :desc => "Chef cookbooks git repository URL.", + :aliases => "-c" method_option "cookbooks-path", :type => :string, - :banner => "Install path to chef cookbooks git repository.", - :default => "/var/chef-solo" - method_option "config-repo", :type => :string, :banner => - "Chef configuration git repository URL." + :desc => "Install path to chef cookbooks git repository.", + :default => "/var/chef-solo", + :aliases => "-p" + method_option "cookbooks-rake-update", :type => :boolean, :desc => + "Run rake update vs. git submodule init/update when updating cookbooks repo", + :default => false, + :aliases => "-u" + method_option "config-repo", :type => :string, + :desc => "Chef configuration git repository URL.", + :aliases => "-C" method_option "config-path", :type => :string, - :banner => "Install path to chef configuration git repository.", - :default => "/etc/chef" + :desc => "Install path to chef configuration git repository.", + :default => "/etc/chef", + :aliases => "-P" + method_option "config-rake-update", :type => :boolean, :desc => + "Run rake update vs. git submodule init/update when updating config repo", + :default => false, + :aliases => "-U" def execute(ssh_host) @ssh_host = ssh_host abort ">> HOST must be set" unless @ssh_host setup_config options @@ -101,18 +134,30 @@ :"config-path" => options["config-path"] config.find_and_execute_task "chef:execute:solo" end desc "update HOST", "Updates and executes chef solo on remote SSH host HOST" - method_option "ruby", :type => :string, :banner => - "Version of ruby to install.", :default => "ree-1.8.7" + method_option "ruby", :type => :string, + :desc => "Version of ruby to install.", + :default => "ree-1.8.7", + :aliases => "-r" method_option "cookbooks-path", :type => :string, - :banner => "Install path to chef cookbooks git repository.", - :default => "/var/chef-solo" + :desc => "Install path to chef cookbooks git repository.", + :default => "/var/chef-solo", + :aliases => "-p" + method_option "cookbooks-rake-update", :type => :boolean, :desc => + "Run rake update vs. git submodule init/update when updating cookbooks repo", + :default => false, + :aliases => "-u" method_option "config-path", :type => :string, - :banner => "Install path to chef configuration git repository.", - :default => "/etc/chef" + :desc => "Install path to chef configuration git repository.", + :default => "/etc/chef", + :aliases => "-P" + method_option "config-rake-update", :type => :boolean, :desc => + "Run rake update vs. git submodule init/update when updating config repo", + :default => false, + :aliases => "-U" def update(ssh_host) @ssh_host = ssh_host abort ">> HOST must be set" unless @ssh_host setup_config options @@ -139,16 +184,24 @@ config end def setup_config(options) [ - {:sym => :ruby, :opt => "ruby"}, - {:sym => :cookbooks_repo, :opt => "cookbooks-repo"}, - {:sym => :cookbooks_path, :opt => "cookbooks-path"}, - {:sym => :config_repo, :opt => "config-repo"}, - {:sym => :config_path, :opt => "config-path"} + {:sym => :ruby, :opt => "ruby"}, + {:sym => :cookbooks_repo, :opt => "cookbooks-repo"}, + {:sym => :cookbooks_path, :opt => "cookbooks-path"}, + {:sym => :config_repo, :opt => "config-repo"}, + {:sym => :config_path, :opt => "config-path"} ].each do |var| config.set(var[:sym], options[var[:opt]]) if options[var[:opt]] + end + + # booleans + [ + {:sym => :cookbooks_rake_update, :opt => "cookbooks-rake-update"}, + {:sym => :config_rake_update, :opt => "config-rake-update"} + ].each do |var| + config.set(var[:sym], options[var[:opt]]) end end end end