From 69bb33d8a781e4793758b7f84b3575cbec2ec3c4 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 11 Oct 2005 01:59:19 +0000 Subject: [PATCH] Use -S switch to set variables before reading recipe files #2242 git-svn-id: http://svn.rubyonrails.org/rails/tools/switchtower@2528 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- CHANGELOG | 2 ++ lib/switchtower/cli.rb | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9815dea8..5b2a4a08 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Use -S switch to set variables before reading recipe files #2242 + * Have setup.rb create a switchtower.cmd file on Win32 platforms #2402 * Add diff_from_last_deploy to the rails switchtower rakefile template diff --git a/lib/switchtower/cli.rb b/lib/switchtower/cli.rb index 55968e6d..1feba977 100644 --- a/lib/switchtower/cli.rb +++ b/lib/switchtower/cli.rb @@ -36,7 +36,8 @@ module SwitchTower def initialize(args = ARGV) @args = args - @options = { :verbose => 0, :recipes => [], :actions => [], :vars => {} } + @options = { :verbose => 0, :recipes => [], :actions => [], :vars => {}, + :pre_vars => {} } OptionParser.new do |opts| opts.banner = "Usage: #{$0} [options] [args]" @@ -70,6 +71,14 @@ module SwitchTower @options[:vars][name.to_sym] = value end + opts.on("-S", "--set-before NAME=VALUE", + "Specify a variable and it's value to set. This", + "will be set BEFORE loading all recipe files." + ) do |pair| + name, value = pair.split(/=/, 2) + @options[:pre_vars][name.to_sym] = value + end + opts.separator "" opts.separator "Framework Integration Options --------" opts.separator "" @@ -171,7 +180,10 @@ DETAIL config.set :password, options[:password] config.set :pretend, options[:pretend] - config.load "standard" # load the standard recipe definition + options[:pre_vars].each { |name, value| config.set(name, value) } + + # load the standard recipe definition + config.load "standard" options[:recipes].each { |recipe| config.load(recipe) } options[:vars].each { |name, value| config.set(name, value) }