From 76e7de61c97f7b9bfff0e6e36eee290a551acb45 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Sat, 27 Aug 2005 17:12:08 +0000 Subject: SwitchTower: allow variables to be set via the cli using the -s switch git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2061 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- switchtower/bin/switchtower | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'switchtower/bin') diff --git a/switchtower/bin/switchtower b/switchtower/bin/switchtower index 7cb8f9228f..d567ad7555 100755 --- a/switchtower/bin/switchtower +++ b/switchtower/bin/switchtower @@ -27,7 +27,7 @@ rescue LoadError end end -options = { :verbose => 0, :recipes => [], :actions => [] } +options = { :verbose => 0, :recipes => [], :actions => [], :vars => {} } OptionParser.new do |opts| opts.banner = "Usage: #{$0} [options]" @@ -56,6 +56,14 @@ OptionParser.new do |opts| "be specified, and are loaded in the given order." ) { |value| options[:recipes] << value } + opts.on("-s", "--set NAME=VALUE", + "Specify a variable and it's value to set. This", + "will be set after loading all recipe files." + ) do |pair| + name, value = pair.split(/=/) + options[:vars][name.to_sym] = value + end + opts.on("-v", "--verbose", "Specify the verbosity of the output.", "May be given multiple times. (Default: silent)" @@ -104,6 +112,7 @@ config.set :pretend, options[:pretend] config.load "standard" # load the standard recipe definition options[:recipes].each { |recipe| config.load(recipe) } +options[:vars].each { |name, value| config.set(name, value) } actor = config.actor options[:actions].each { |action| actor.send action } -- cgit v1.2.3