1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Added support for ~/.caprc and -x/-c switches.

git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@5774 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2006-12-23 16:09:27 +00:00
parent dcb8c3ebdf
commit 46e1b364cf
2 changed files with 28 additions and 1 deletions

View file

@ -1,5 +1,7 @@
*SVN*
* Added support for ~/.caprc, also -x and -c switches.
* Updated migrate action to use db:migrate task in Rails instead of the deprecated migrate task [DHH]
* Allow SSH user and port to be encoded in the hostname strings [Ezra Zygmuntowicz]

View file

@ -96,7 +96,7 @@ module Capistrano
def initialize(args = ARGV)
@args = args
@options = { :recipes => [], :actions => [], :vars => {},
:pre_vars => {} }
:pre_vars => {}, :dotfile => default_dotfile }
OptionParser.new do |opts|
opts.banner = "Usage: #{$0} [options] [args]"
@ -110,6 +110,14 @@ module Capistrano
"be specified, and are loaded in the given order."
) { |value| @options[:actions] << value }
opts.on("-c", "--caprc FILE",
"Specify an alternate personal config file to load.",
"(Default: #{@options[:dotfile]})"
) do |value|
abort "The config file `#{value}' does not exist" unless File.exist?(value)
@options[:dotfile] = value
end
opts.on("-f", "--file FILE",
"A recipe file to load. Multiple recipes may",
"be specified, and are loaded in the given order."
@ -147,6 +155,12 @@ module Capistrano
@options[:pre_vars][name.to_sym] = value
end
opts.on("-x", "--skip-config",
"Disables the loading of the default personal config",
"file. Specifying -C after this option will reenable",
"it. (Default: config file is loaded)"
) { @options[:dotfile] = nil }
opts.separator ""
opts.separator "Framework Integration Options --------"
opts.separator ""
@ -245,6 +259,7 @@ DETAIL
config.set :pretend, options[:pretend]
options[:pre_vars].each { |name, value| config.set(name, value) }
config.load(@options[:dotfile]) if @options[:dotfile] && File.exist?(@options[:dotfile])
# load the standard recipe definition
config.load "standard"
@ -288,6 +303,16 @@ DETAIL
end
end
def default_dotfile
File.join(home_directory, ".caprc")
end
def home_directory
ENV["HOME"] ||
(ENV["HOMEPATH"] && "#{ENV["HOMEDRIVE"]}#{ENV["HOMEPATH"]}") ||
"/"
end
def look_for_default_recipe_file!
DEFAULT_RECIPES.each do |file|
if File.exist?(file)