capistrano 2.0.0 → 2.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +7 -0
- data/CHANGELOG +715 -18
- data/Gemfile +12 -0
- data/README.md +94 -0
- data/Rakefile +11 -0
- data/bin/cap +0 -0
- data/bin/capify +37 -22
- data/capistrano.gemspec +40 -0
- data/lib/capistrano/callback.rb +5 -1
- data/lib/capistrano/cli/execute.rb +10 -7
- data/lib/capistrano/cli/help.rb +39 -16
- data/lib/capistrano/cli/help.txt +44 -16
- data/lib/capistrano/cli/options.rb +71 -11
- data/lib/capistrano/cli/ui.rb +13 -1
- data/lib/capistrano/cli.rb +5 -5
- data/lib/capistrano/command.rb +215 -58
- data/lib/capistrano/configuration/actions/file_transfer.rb +29 -14
- data/lib/capistrano/configuration/actions/inspect.rb +3 -3
- data/lib/capistrano/configuration/actions/invocation.rb +212 -22
- data/lib/capistrano/configuration/alias_task.rb +26 -0
- data/lib/capistrano/configuration/callbacks.rb +26 -27
- data/lib/capistrano/configuration/connections.rb +130 -52
- data/lib/capistrano/configuration/execution.rb +34 -18
- data/lib/capistrano/configuration/loading.rb +91 -6
- data/lib/capistrano/configuration/log_formatters.rb +75 -0
- data/lib/capistrano/configuration/namespaces.rb +45 -12
- data/lib/capistrano/configuration/roles.rb +28 -2
- data/lib/capistrano/configuration/servers.rb +51 -10
- data/lib/capistrano/configuration/variables.rb +3 -3
- data/lib/capistrano/configuration.rb +20 -4
- data/lib/capistrano/errors.rb +12 -8
- data/lib/capistrano/ext/multistage.rb +62 -0
- data/lib/capistrano/ext/string.rb +5 -0
- data/lib/capistrano/extensions.rb +1 -1
- data/lib/capistrano/fix_rake_deprecated_dsl.rb +8 -0
- data/lib/capistrano/logger.rb +112 -5
- data/lib/capistrano/processable.rb +55 -0
- data/lib/capistrano/recipes/compat.rb +2 -2
- data/lib/capistrano/recipes/deploy/assets.rb +185 -0
- data/lib/capistrano/recipes/deploy/dependencies.rb +2 -2
- data/lib/capistrano/recipes/deploy/local_dependency.rb +10 -2
- data/lib/capistrano/recipes/deploy/remote_dependency.rb +54 -2
- data/lib/capistrano/recipes/deploy/scm/accurev.rb +169 -0
- data/lib/capistrano/recipes/deploy/scm/base.rb +31 -11
- data/lib/capistrano/recipes/deploy/scm/bzr.rb +14 -14
- data/lib/capistrano/recipes/deploy/scm/cvs.rb +10 -8
- data/lib/capistrano/recipes/deploy/scm/darcs.rb +12 -1
- data/lib/capistrano/recipes/deploy/scm/git.rb +293 -0
- data/lib/capistrano/recipes/deploy/scm/mercurial.rb +23 -15
- data/lib/capistrano/recipes/deploy/scm/none.rb +55 -0
- data/lib/capistrano/recipes/deploy/scm/perforce.rb +54 -28
- data/lib/capistrano/recipes/deploy/scm/subversion.rb +35 -17
- data/lib/capistrano/recipes/deploy/scm.rb +1 -1
- data/lib/capistrano/recipes/deploy/strategy/base.rb +32 -4
- data/lib/capistrano/recipes/deploy/strategy/copy.rb +238 -43
- data/lib/capistrano/recipes/deploy/strategy/remote.rb +1 -1
- data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +11 -1
- data/lib/capistrano/recipes/deploy/strategy/unshared_remote_cache.rb +21 -0
- data/lib/capistrano/recipes/deploy/strategy.rb +1 -1
- data/lib/capistrano/recipes/deploy.rb +265 -123
- data/lib/capistrano/recipes/standard.rb +1 -1
- data/lib/capistrano/role.rb +102 -0
- data/lib/capistrano/server_definition.rb +6 -1
- data/lib/capistrano/shell.rb +30 -33
- data/lib/capistrano/ssh.rb +46 -60
- data/lib/capistrano/task_definition.rb +16 -8
- data/lib/capistrano/transfer.rb +218 -0
- data/lib/capistrano/version.rb +6 -17
- data/lib/capistrano.rb +4 -1
- data/test/cli/execute_test.rb +3 -3
- data/test/cli/help_test.rb +33 -7
- data/test/cli/options_test.rb +109 -6
- data/test/cli/ui_test.rb +2 -2
- data/test/cli_test.rb +3 -3
- data/test/command_test.rb +144 -124
- data/test/configuration/actions/file_transfer_test.rb +41 -20
- data/test/configuration/actions/inspect_test.rb +21 -7
- data/test/configuration/actions/invocation_test.rb +91 -30
- data/test/configuration/alias_task_test.rb +118 -0
- data/test/configuration/callbacks_test.rb +41 -46
- data/test/configuration/connections_test.rb +187 -36
- data/test/configuration/execution_test.rb +18 -2
- data/test/configuration/loading_test.rb +17 -4
- data/test/configuration/namespace_dsl_test.rb +54 -5
- data/test/configuration/roles_test.rb +114 -4
- data/test/configuration/servers_test.rb +97 -4
- data/test/configuration/variables_test.rb +12 -2
- data/test/configuration_test.rb +9 -13
- data/test/deploy/local_dependency_test.rb +76 -0
- data/test/deploy/remote_dependency_test.rb +146 -0
- data/test/deploy/scm/accurev_test.rb +23 -0
- data/test/deploy/scm/base_test.rb +1 -1
- data/test/deploy/scm/bzr_test.rb +51 -0
- data/test/deploy/scm/darcs_test.rb +37 -0
- data/test/deploy/scm/git_test.rb +221 -0
- data/test/deploy/scm/mercurial_test.rb +134 -0
- data/test/deploy/scm/none_test.rb +35 -0
- data/test/deploy/scm/perforce_test.rb +23 -0
- data/test/deploy/scm/subversion_test.rb +40 -0
- data/test/deploy/strategy/copy_test.rb +240 -26
- data/test/extensions_test.rb +2 -2
- data/test/logger_formatting_test.rb +149 -0
- data/test/logger_test.rb +13 -2
- data/test/recipes_test.rb +25 -0
- data/test/role_test.rb +11 -0
- data/test/server_definition_test.rb +15 -2
- data/test/shell_test.rb +33 -1
- data/test/ssh_test.rb +40 -24
- data/test/task_definition_test.rb +18 -2
- data/test/transfer_test.rb +168 -0
- data/test/utils.rb +27 -33
- metadata +215 -102
- data/MIT-LICENSE +0 -20
- data/README +0 -43
- data/examples/sample.rb +0 -14
- data/lib/capistrano/gateway.rb +0 -131
- data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/recipes/upgrade.rb +0 -33
- data/lib/capistrano/upload.rb +0 -146
- data/test/gateway_test.rb +0 -167
- data/test/upload_test.rb +0 -131
- data/test/version_test.rb +0 -24
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
## Capistrano
|
|
2
|
+
|
|
3
|
+
[](http://travis-ci.org/capistrano/capistrano)[](https://codeclimate.com/github/capistrano/capistrano)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Capistrano is a utility and framework for executing commands in parallel on
|
|
8
|
+
multiple remote machines, via SSH. It uses a simple DSL (borrowed in part from
|
|
9
|
+
[Rake](http://rake.rubyforge.org/)) that allows you to define _tasks_, which may
|
|
10
|
+
be applied to machines in certain roles. It also supports tunneling connections
|
|
11
|
+
via some gateway machine to allow operations to be performed behind VPN's and
|
|
12
|
+
firewalls.
|
|
13
|
+
|
|
14
|
+
Capistrano was originally designed to simplify and automate deployment of web
|
|
15
|
+
applications to distributed environments, and originally came bundled with a set
|
|
16
|
+
of tasks designed for deploying Rails applications.
|
|
17
|
+
|
|
18
|
+
## Documentation
|
|
19
|
+
|
|
20
|
+
* [https://github.com/capistrano/capistrano/wiki](https://github.com/capistrano/capistrano/wiki)
|
|
21
|
+
|
|
22
|
+
## DEPENDENCIES
|
|
23
|
+
|
|
24
|
+
* [Net::SSH](http://net-ssh.rubyforge.org)
|
|
25
|
+
* [Net::SFTP](http://net-ssh.rubyforge.org)
|
|
26
|
+
* [Net::SCP](http://net-ssh.rubyforge.org)
|
|
27
|
+
* [Net::SSH::Gateway](http://net-ssh.rubyforge.org)
|
|
28
|
+
* [HighLine](http://highline.rubyforge.org)
|
|
29
|
+
* [Ruby](http://www.ruby-lang.org/en/) ≥ 1.8.7
|
|
30
|
+
|
|
31
|
+
If you want to run the tests, you'll also need to install the dependencies with
|
|
32
|
+
Bundler, see the `Gemfile` within .
|
|
33
|
+
|
|
34
|
+
## ASSUMPTIONS
|
|
35
|
+
|
|
36
|
+
Capistrano is "opinionated software", which means it has very firm ideas about
|
|
37
|
+
how things ought to be done, and tries to force those ideas on you. Some of the
|
|
38
|
+
assumptions behind these opinions are:
|
|
39
|
+
|
|
40
|
+
* You are using SSH to access the remote servers.
|
|
41
|
+
* You either have the same password to all target machines, or you have public
|
|
42
|
+
keys in place to allow passwordless access to them.
|
|
43
|
+
|
|
44
|
+
Do not expect these assumptions to change.
|
|
45
|
+
|
|
46
|
+
## USAGE
|
|
47
|
+
|
|
48
|
+
In general, you'll use Capistrano as follows:
|
|
49
|
+
|
|
50
|
+
* Create a recipe file ("capfile" or "Capfile").
|
|
51
|
+
* Use the `cap` script to execute your recipe.
|
|
52
|
+
|
|
53
|
+
Use the `cap` script as follows:
|
|
54
|
+
|
|
55
|
+
cap sometask
|
|
56
|
+
|
|
57
|
+
By default, the script will look for a file called one of `capfile` or
|
|
58
|
+
`Capfile`. The `sometask` text indicates which task to execute. You can do
|
|
59
|
+
"cap -h" to see all the available options and "cap -T" to see all the available
|
|
60
|
+
tasks.
|
|
61
|
+
|
|
62
|
+
## CONTRIBUTING:
|
|
63
|
+
|
|
64
|
+
* Fork Capistrano
|
|
65
|
+
* Create a topic branch - `git checkout -b my_branch`
|
|
66
|
+
* Rebase your branch so that all your changes are reflected in one
|
|
67
|
+
commit
|
|
68
|
+
* Push to your branch - `git push origin my_branch`
|
|
69
|
+
* Create a Pull Request from your branch, include as much documentation
|
|
70
|
+
as you can in the commit message/pull request, following these
|
|
71
|
+
[guidelines on writing a good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
|
|
72
|
+
* That's it!
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
## LICENSE:
|
|
76
|
+
|
|
77
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
78
|
+
a copy of this software and associated documentation files (the
|
|
79
|
+
'Software'), to deal in the Software without restriction, including
|
|
80
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
81
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
82
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
83
|
+
the following conditions:
|
|
84
|
+
|
|
85
|
+
The above copyright notice and this permission notice shall be
|
|
86
|
+
included in all copies or substantial portions of the Software.
|
|
87
|
+
|
|
88
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
89
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
90
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
91
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
92
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
93
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
94
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/cap
CHANGED
|
File without changes
|
data/bin/capify
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
3
|
require 'optparse'
|
|
4
|
+
require 'fileutils'
|
|
4
5
|
|
|
5
6
|
OptionParser.new do |opts|
|
|
6
7
|
opts.banner = "Usage: #{File.basename($0)} [path]"
|
|
@@ -36,40 +37,54 @@ end
|
|
|
36
37
|
|
|
37
38
|
files = {
|
|
38
39
|
"Capfile" => unindent(<<-FILE),
|
|
39
|
-
|
|
40
|
-
load '
|
|
40
|
+
|
|
41
|
+
load 'deploy'
|
|
42
|
+
|
|
43
|
+
# Uncomment if you are using Rails' asset pipeline
|
|
44
|
+
# load 'deploy/assets'
|
|
45
|
+
|
|
46
|
+
load 'config/deploy' # remove this line to skip loading any of the default tasks
|
|
41
47
|
FILE
|
|
42
48
|
|
|
43
|
-
"config/deploy.rb" =>
|
|
44
|
-
|
|
45
|
-
set :repository, "set your repository location here"
|
|
49
|
+
"config/deploy.rb" => 'set :application, "set your application name here"
|
|
50
|
+
set :repository, "set your repository location here"
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
# via the :deploy_to variable:
|
|
50
|
-
# set :deploy_to, "/var/www/\#{application}"
|
|
52
|
+
# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
|
|
53
|
+
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
role :web, "your web-server here" # Your HTTP server, Apache/etc
|
|
56
|
+
role :app, "your app-server here" # This may be the same as your `Web` server
|
|
57
|
+
role :db, "your primary db-server here", :primary => true # This is where Rails migrations will run
|
|
58
|
+
role :db, "your slave db-server here"
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
# if you want to clean up old releases on each deploy uncomment this:
|
|
61
|
+
# after "deploy:restart", "deploy:cleanup"
|
|
62
|
+
|
|
63
|
+
# if you\'re still using the script/reaper helper you will need
|
|
64
|
+
# these http://github.com/rails/irs_process_scripts
|
|
65
|
+
|
|
66
|
+
# If you are using Passenger mod_rails uncomment this:
|
|
67
|
+
# namespace :deploy do
|
|
68
|
+
# task :start do ; end
|
|
69
|
+
# task :stop do ; end
|
|
70
|
+
# task :restart, :roles => :app, :except => { :no_release => true } do
|
|
71
|
+
# run "#{try_sudo} touch #{File.join(current_path,\'tmp\',\'restart.txt\')}"
|
|
72
|
+
# end
|
|
73
|
+
# end'}
|
|
61
74
|
|
|
62
75
|
base = ARGV.shift
|
|
63
76
|
files.each do |file, content|
|
|
64
77
|
file = File.join(base, file)
|
|
65
78
|
if File.exists?(file)
|
|
66
|
-
warn "[skip]
|
|
79
|
+
warn "[skip] '#{file}' already exists"
|
|
67
80
|
elsif File.exists?(file.downcase)
|
|
68
|
-
warn "[skip]
|
|
69
|
-
elsif !File.exists?(File.dirname(file))
|
|
70
|
-
warn "[skip] directory `#{File.dirname(file)}' does not exist"
|
|
81
|
+
warn "[skip] '#{file.downcase}' exists, which could conflict with `#{file}'"
|
|
71
82
|
else
|
|
72
|
-
|
|
83
|
+
unless File.exists?(File.dirname(file))
|
|
84
|
+
puts "[add] making directory '#{File.dirname(file)}'"
|
|
85
|
+
FileUtils.mkdir(File.dirname(file))
|
|
86
|
+
end
|
|
87
|
+
puts "[add] writing '#{file}'"
|
|
73
88
|
File.open(file, "w") { |f| f.write(content) }
|
|
74
89
|
end
|
|
75
90
|
end
|
data/capistrano.gemspec
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "capistrano/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
|
|
7
|
+
s.name = "capistrano"
|
|
8
|
+
s.version = Capistrano::Version.to_s
|
|
9
|
+
s.platform = Gem::Platform::RUBY
|
|
10
|
+
s.authors = ["Jamis Buck", "Lee Hambley"]
|
|
11
|
+
s.email = ["jamis@jamisbuck.org", "lee.hambley@gmail.com"]
|
|
12
|
+
s.homepage = "http://github.com/capistrano/capistrano"
|
|
13
|
+
s.summary = %q{Capistrano - Welcome to easy deployment with Ruby over SSH}
|
|
14
|
+
s.description = %q{Capistrano is a utility and framework for executing commands in parallel on multiple remote machines, via SSH.}
|
|
15
|
+
s.files = `git ls-files`.split("\n")
|
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
18
|
+
s.require_paths = ["lib"]
|
|
19
|
+
s.extra_rdoc_files = [
|
|
20
|
+
"README.md"
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
s.specification_version = 3 if s.respond_to? :specification_version
|
|
24
|
+
|
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
26
|
+
s.add_runtime_dependency(%q<highline>, [">= 0"])
|
|
27
|
+
s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.14"])
|
|
28
|
+
s.add_runtime_dependency(%q<net-sftp>, [">= 2.0.0"])
|
|
29
|
+
s.add_runtime_dependency(%q<net-scp>, [">= 1.0.0"])
|
|
30
|
+
s.add_runtime_dependency(%q<net-ssh-gateway>, [">= 1.1.0"])
|
|
31
|
+
s.add_development_dependency(%q<mocha>, ["0.9.12"])
|
|
32
|
+
else
|
|
33
|
+
s.add_dependency(%q<net-ssh>, [">= 2.0.14"])
|
|
34
|
+
s.add_dependency(%q<net-sftp>, [">= 2.0.0"])
|
|
35
|
+
s.add_dependency(%q<net-scp>, [">= 1.0.0"])
|
|
36
|
+
s.add_dependency(%q<net-ssh-gateway>, [">= 1.1.0"])
|
|
37
|
+
s.add_dependency(%q<highline>, [">= 0"])
|
|
38
|
+
s.add_dependency(%q<mocha>, ["0.9.12"])
|
|
39
|
+
end
|
|
40
|
+
end
|
data/lib/capistrano/callback.rb
CHANGED
|
@@ -21,7 +21,10 @@ module Capistrano
|
|
|
21
21
|
#
|
|
22
22
|
# Returns the Configuration instance used, if successful.
|
|
23
23
|
def execute!
|
|
24
|
-
config = instantiate_configuration
|
|
24
|
+
config = instantiate_configuration(options)
|
|
25
|
+
config.debug = options[:debug]
|
|
26
|
+
config.dry_run = options[:dry_run]
|
|
27
|
+
config.preserve_roles = options[:preserve_roles]
|
|
25
28
|
config.logger.level = options[:verbose]
|
|
26
29
|
|
|
27
30
|
set_pre_vars(config)
|
|
@@ -52,10 +55,10 @@ module Capistrano
|
|
|
52
55
|
def load_recipes(config) #:nodoc:
|
|
53
56
|
# load the standard recipe definition
|
|
54
57
|
config.load "standard"
|
|
55
|
-
|
|
58
|
+
|
|
56
59
|
# load systemwide config/recipe definition
|
|
57
|
-
config.load(options[:sysconf]) if options[:sysconf] && File.file?(options[:sysconf])
|
|
58
|
-
|
|
60
|
+
config.load(options[:sysconf]) if options[:sysconf] && File.file?(options[:sysconf])
|
|
61
|
+
|
|
59
62
|
# load user config/recipe definition
|
|
60
63
|
config.load(options[:dotfile]) if options[:dotfile] && File.file?(options[:dotfile])
|
|
61
64
|
|
|
@@ -64,8 +67,8 @@ module Capistrano
|
|
|
64
67
|
|
|
65
68
|
# Primarily useful for testing, but subclasses of CLI could conceivably
|
|
66
69
|
# override this method to return a Configuration subclass or replacement.
|
|
67
|
-
def instantiate_configuration #:nodoc:
|
|
68
|
-
Capistrano::Configuration.new
|
|
70
|
+
def instantiate_configuration(options={}) #:nodoc:
|
|
71
|
+
Capistrano::Configuration.new(options)
|
|
69
72
|
end
|
|
70
73
|
|
|
71
74
|
def handle_error(error) #:nodoc:
|
|
@@ -79,4 +82,4 @@ module Capistrano
|
|
|
79
82
|
end
|
|
80
83
|
end
|
|
81
84
|
end
|
|
82
|
-
end
|
|
85
|
+
end
|
data/lib/capistrano/cli/help.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Capistrano
|
|
|
12
12
|
|
|
13
13
|
def execute_requested_actions_with_help(config)
|
|
14
14
|
if options[:tasks]
|
|
15
|
-
task_list(config)
|
|
15
|
+
task_list(config, options[:tasks])
|
|
16
16
|
elsif options[:explain]
|
|
17
17
|
explain_task(config, options[:explain])
|
|
18
18
|
else
|
|
@@ -20,11 +20,19 @@ module Capistrano
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def task_list(config) #:nodoc:
|
|
24
|
-
|
|
23
|
+
def task_list(config, pattern = true) #:nodoc:
|
|
24
|
+
tool_output = options[:tool]
|
|
25
|
+
|
|
26
|
+
if pattern.is_a?(String)
|
|
27
|
+
tasks = config.task_list(:all).select {|t| t.fully_qualified_name =~ /#{pattern}/}
|
|
28
|
+
end
|
|
29
|
+
if tasks.nil? || tasks.length == 0
|
|
30
|
+
warn "Pattern '#{pattern}' not found. Listing all tasks.\n\n" if !tool_output && !pattern.is_a?(TrueClass)
|
|
31
|
+
tasks = config.task_list(:all)
|
|
32
|
+
end
|
|
25
33
|
|
|
26
34
|
if tasks.empty?
|
|
27
|
-
warn "There are no tasks available. Please specify a recipe file to load."
|
|
35
|
+
warn "There are no tasks available. Please specify a recipe file to load." unless tool_output
|
|
28
36
|
else
|
|
29
37
|
all_tasks_length = tasks.length
|
|
30
38
|
if options[:verbose].to_i < 1
|
|
@@ -38,19 +46,25 @@ module Capistrano
|
|
|
38
46
|
max_length = MIN_MAX_LEN if max_length < MIN_MAX_LEN
|
|
39
47
|
|
|
40
48
|
tasks.each do |task|
|
|
41
|
-
|
|
49
|
+
if tool_output
|
|
50
|
+
puts "cap #{task.fully_qualified_name}"
|
|
51
|
+
else
|
|
52
|
+
puts "cap %-#{longest}s # %s" % [task.fully_qualified_name, task.brief_description(max_length)]
|
|
53
|
+
end
|
|
42
54
|
end
|
|
43
55
|
|
|
44
|
-
|
|
56
|
+
unless tool_output
|
|
57
|
+
if all_tasks_length > tasks.length
|
|
58
|
+
puts
|
|
59
|
+
puts "Some tasks were not listed, either because they have no description,"
|
|
60
|
+
puts "or because they are only used internally by other tasks. To see all"
|
|
61
|
+
puts "tasks, type `#{File.basename($0)} -vT'."
|
|
62
|
+
end
|
|
63
|
+
|
|
45
64
|
puts
|
|
46
|
-
puts "
|
|
47
|
-
puts "
|
|
48
|
-
puts "tasks, type `#{File.basename($0)} -Tv'."
|
|
65
|
+
puts "Extended help may be available for these tasks."
|
|
66
|
+
puts "Type `#{File.basename($0)} -e taskname' to view it."
|
|
49
67
|
end
|
|
50
|
-
|
|
51
|
-
puts
|
|
52
|
-
puts "Extended help may be available for these tasks."
|
|
53
|
-
puts "Type `#{File.basename($0)} -e taskname' to view it."
|
|
54
68
|
end
|
|
55
69
|
end
|
|
56
70
|
|
|
@@ -84,7 +98,9 @@ module Capistrano
|
|
|
84
98
|
text.each_line do |line|
|
|
85
99
|
indentation = line[/^\s+/] || ""
|
|
86
100
|
indentation_size = indentation.split(//).inject(0) { |c,s| c + (s[0] == ?\t ? 8 : 1) }
|
|
87
|
-
|
|
101
|
+
line_length = output_columns - indentation_size
|
|
102
|
+
line_length = MIN_MAX_LEN if line_length < MIN_MAX_LEN
|
|
103
|
+
lines = line.strip.gsub(/(.{1,#{line_length}})(?:\s+|\Z)/, "\\1\n").split(/\n/)
|
|
88
104
|
if lines.empty?
|
|
89
105
|
formatted << "\n"
|
|
90
106
|
else
|
|
@@ -95,8 +111,15 @@ module Capistrano
|
|
|
95
111
|
end
|
|
96
112
|
|
|
97
113
|
def output_columns #:nodoc:
|
|
98
|
-
@output_columns
|
|
114
|
+
if ( @output_columns.nil? )
|
|
115
|
+
if ( self.class.ui.output_cols.nil? )
|
|
116
|
+
@output_columns = 80
|
|
117
|
+
else
|
|
118
|
+
@output_columns = self.class.ui.output_cols
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
@output_columns
|
|
99
122
|
end
|
|
100
123
|
end
|
|
101
124
|
end
|
|
102
|
-
end
|
|
125
|
+
end
|
data/lib/capistrano/cli/help.txt
CHANGED
|
@@ -6,48 +6,76 @@ Capistrano is a utility for automating the execution of commands across multiple
|
|
|
6
6
|
|
|
7
7
|
The command-line interface to Capistrano is via the `cap' command.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
cap [ option ] ... action ...
|
|
10
10
|
|
|
11
11
|
The following options are understood:
|
|
12
12
|
|
|
13
|
+
<%= color '-d, --debug', :bold %>
|
|
14
|
+
Causes Capistrano to pause and prompt before executing any remote command, giving the user the option to either execute the command, skip the command, or abort execution entirely. This makes it a great way to troubleshoot tasks, or test custom tasks, by executing commands one at a time and checking the server to make sure they worked as expected before moving on to the next command. (Compare this to the --dry-run command.)
|
|
15
|
+
|
|
13
16
|
<%= color '-e, --explain TASK', :bold %>
|
|
14
|
-
|
|
17
|
+
Displays the extended description of the given task. Not all tasks will have an extended description, but for those that do, this can provide a wealth of additional usage information, such as describing environment variables or settings that can affect the execution of the task.
|
|
15
18
|
|
|
16
19
|
<%= color '-F, --default-config', :bold %>
|
|
17
|
-
|
|
20
|
+
By default, cap will search for a config file named `Capfile' or `capfile' in the current directory, or in any parent directory, and will automatically load it. However, if you specify the -f flag (see below), cap will use that file instead of the default config. If you want to use both the default config, and files loaded via -f, you can specify -F to force cap to search for and load the default config, even if additional files were specified via -f.
|
|
18
21
|
|
|
19
22
|
<%= color '-f, --file FILE', :bold %>
|
|
20
|
-
|
|
23
|
+
Causes the named file to be loaded. Capistrano will search both its own recipe directory, as well as the current directory, looking for the named file. An ".rb" extension is optional. The -f option may be given any number of times, but if it is given, it will take the place of the normal `Capfile' or `capfile' detection. Use -F if you want the default capfile to be loaded when you use -f.
|
|
21
24
|
|
|
22
25
|
<%= color '-H, --long-help', :bold %>
|
|
23
|
-
|
|
26
|
+
Displays this document and exits.
|
|
24
27
|
|
|
25
28
|
<%= color '-h, --help', :bold %>
|
|
26
|
-
|
|
29
|
+
Shows a brief summary of these options and exits.
|
|
30
|
+
|
|
31
|
+
<%= color '-l, --logger [STDERR|STDOUT|file]', :bold %>
|
|
32
|
+
Change the file used to print the output. It offers three options: standard error(stderr), standard output and file. Options are not case sensitive. By default Capistrano uses stderr.
|
|
33
|
+
|
|
34
|
+
<%= color '-n, --dry-run', :bold %>
|
|
35
|
+
Causes Capistrano to simply display each remote command, without executing it. In this sense it is similar to --debug, but without the prompt. Note that commands executed locally are still run--only remote commands are skipped.
|
|
27
36
|
|
|
28
37
|
<%= color '-p, --password', :bold %>
|
|
29
|
-
|
|
38
|
+
Normally, cap will prompt for the password on-demand, the first time it is needed. This can make it hard to walk away from Capistrano, since you might not know if it will prompt for a password down the road. In such cases, you can use the -p option to force cap to prompt for the password immediately.
|
|
30
39
|
|
|
31
40
|
<%= color '-q, --quiet', :bold %>
|
|
32
|
-
|
|
41
|
+
Display only critical error messages. All other output is suppressed.
|
|
33
42
|
|
|
34
43
|
<%= color '-S, --set-before NAME=VALUE', :bold %>
|
|
35
|
-
|
|
44
|
+
Sets the given variable to the given value, before loading any recipe files. This is useful if you have a recipe file that depends on a certain variable being set, at the time it is loaded.
|
|
36
45
|
|
|
37
46
|
<%= color '-s, --set NAME=VALUE', :bold %>
|
|
38
|
-
|
|
47
|
+
Sets the given variable to the given value, after loading all recipe files. This is useful when you want to override the value of a variable which is used in a task. Note that this will set the variables too late for them to affect conditions that are executed as the recipes are loaded.
|
|
39
48
|
|
|
40
|
-
<%= color '-T, --tasks', :bold %>
|
|
41
|
-
|
|
49
|
+
<%= color '-T, --tasks PATTERN', :bold %>
|
|
50
|
+
Displays the list of all tasks (matching optional PATTERN) in all loaded recipe files. If a task has no description, or if the description starts with the [internal] tag, the task will not be listed unless you also specify -v.
|
|
51
|
+
|
|
52
|
+
<%= color '-t, --tool', :bold %>
|
|
53
|
+
Abbreviates the output of -T for integration with other tools. Without -t, -T will list tasks with their summaries, and may include additional instructive text at the bottom. When integrating with other tools (e.g., bash auto-expansion and the like) that additional text can get in the way. This switch makes it easier for those tools to parse the list of tasks. (The -t switch has no effect if the -T switch is not specified.)
|
|
42
54
|
|
|
43
55
|
<%= color '-V, --version', :bold %>
|
|
44
|
-
|
|
56
|
+
Shows the current Capistrano version number and exits.
|
|
45
57
|
|
|
46
58
|
<%= color '-v, --verbose', :bold %>
|
|
47
|
-
|
|
59
|
+
Increase the verbosity. You can specify this option up to three times to further increase verbosity. By default, cap will use maximum verbosity, but if you specify an explicit verbosity, that will be used instead. See also -q.
|
|
48
60
|
|
|
49
61
|
<%= color '-X, --skip-system-config', :bold %>
|
|
50
|
-
|
|
62
|
+
By default, cap will look for and (if it exists) load the global system configuration file located in /etc/capistrano.conf. If you don't want cap to load that file, give this option.
|
|
51
63
|
|
|
52
64
|
<%= color '-x, --skip-user-config', :bold %>
|
|
53
|
-
|
|
65
|
+
By default, cap will look for and (if it exists) load the user-specific configuration file located in $HOME/.caprc. If you don't want cap to load that file, give this option.
|
|
66
|
+
|
|
67
|
+
-----------------------------
|
|
68
|
+
<%= color('Environment Variables', :bold) %>
|
|
69
|
+
-----------------------------
|
|
70
|
+
|
|
71
|
+
<%= color 'HOSTS', :bold %>
|
|
72
|
+
Execute the tasks against this comma-separated list of hosts. Effectively, this makes the host(s) part of every roles.
|
|
73
|
+
|
|
74
|
+
<%= color 'HOSTFILTER', :bold %>
|
|
75
|
+
Execute tasks against this comma-separated list of host, but only if the host has the proper role for the task.
|
|
76
|
+
|
|
77
|
+
<%= color 'HOSTROLEFILTER', :bold %>
|
|
78
|
+
Execute tasks against the hosts in this comma-separated list of roles, but only if the host has the proper role for the task.
|
|
79
|
+
|
|
80
|
+
<%= color 'ROLES', :bold %>
|
|
81
|
+
Execute tasks against this comma-separated list of roles. Hosts which do not have the right roles will be skipped.
|
|
@@ -24,9 +24,14 @@ module Capistrano
|
|
|
24
24
|
# line switches for Capistrano, and what their corresponding behaviors
|
|
25
25
|
# are.
|
|
26
26
|
def option_parser #:nodoc:
|
|
27
|
+
@logger = Logger.new
|
|
27
28
|
@option_parser ||= OptionParser.new do |opts|
|
|
28
29
|
opts.banner = "Usage: #{File.basename($0)} [options] action ..."
|
|
29
30
|
|
|
31
|
+
opts.on("-d", "--debug",
|
|
32
|
+
"Prompts before each remote command execution."
|
|
33
|
+
) { |value| options[:debug] = true }
|
|
34
|
+
|
|
30
35
|
opts.on("-e", "--explain TASK",
|
|
31
36
|
"Displays help (if available) for the task."
|
|
32
37
|
) { |value| options[:explain] = value }
|
|
@@ -39,7 +44,7 @@ module Capistrano
|
|
|
39
44
|
"A recipe file to load. May be given more than once."
|
|
40
45
|
) { |value| options[:recipes] << value }
|
|
41
46
|
|
|
42
|
-
opts.on("-H", "--long-help", "Explain these options.") do
|
|
47
|
+
opts.on("-H", "--long-help", "Explain these options and environment variables.") do
|
|
43
48
|
long_help
|
|
44
49
|
exit
|
|
45
50
|
end
|
|
@@ -49,14 +54,35 @@ module Capistrano
|
|
|
49
54
|
exit
|
|
50
55
|
end
|
|
51
56
|
|
|
57
|
+
opts.on("-l", "--logger [STDERR|STDOUT|file]",
|
|
58
|
+
"Choose logger method. STDERR used by default."
|
|
59
|
+
) do |value|
|
|
60
|
+
options[:output] = if value.nil? || value.upcase == 'STDERR'
|
|
61
|
+
# Using default logger.
|
|
62
|
+
nil
|
|
63
|
+
elsif value.upcase == 'STDOUT'
|
|
64
|
+
$stdout
|
|
65
|
+
else
|
|
66
|
+
value
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
opts.on("-n", "--dry-run",
|
|
71
|
+
"Prints out commands without running them."
|
|
72
|
+
) { |value| options[:dry_run] = true }
|
|
73
|
+
|
|
52
74
|
opts.on("-p", "--password",
|
|
53
75
|
"Immediately prompt for the password."
|
|
54
76
|
) { options[:password] = nil }
|
|
55
77
|
|
|
56
78
|
opts.on("-q", "--quiet",
|
|
57
|
-
"Make the output as quiet as possible
|
|
79
|
+
"Make the output as quiet as possible."
|
|
58
80
|
) { options[:verbose] = 0 }
|
|
59
81
|
|
|
82
|
+
opts.on("-r", "--preserve-roles",
|
|
83
|
+
"Preserve task roles"
|
|
84
|
+
) { options[:preserve_roles] = true }
|
|
85
|
+
|
|
60
86
|
opts.on("-S", "--set-before NAME=VALUE",
|
|
61
87
|
"Set a variable before the recipes are loaded."
|
|
62
88
|
) do |pair|
|
|
@@ -71,24 +97,35 @@ module Capistrano
|
|
|
71
97
|
options[:vars][name.to_sym] = value
|
|
72
98
|
end
|
|
73
99
|
|
|
74
|
-
opts.on("-T", "--tasks",
|
|
75
|
-
"List all tasks in the loaded recipe files."
|
|
76
|
-
) do
|
|
77
|
-
options[:tasks] =
|
|
100
|
+
opts.on("-T", "--tasks [PATTERN]",
|
|
101
|
+
"List all tasks (matching optional PATTERN) in the loaded recipe files."
|
|
102
|
+
) do |value|
|
|
103
|
+
options[:tasks] = if value
|
|
104
|
+
value
|
|
105
|
+
else
|
|
106
|
+
true
|
|
107
|
+
end
|
|
78
108
|
options[:verbose] ||= 0
|
|
79
109
|
end
|
|
80
110
|
|
|
111
|
+
opts.on("-t", "--tool",
|
|
112
|
+
"Abbreviates the output of -T for tool integration."
|
|
113
|
+
) { options[:tool] = true }
|
|
114
|
+
|
|
81
115
|
opts.on("-V", "--version",
|
|
82
116
|
"Display the Capistrano version, and exit."
|
|
83
117
|
) do
|
|
84
118
|
require 'capistrano/version'
|
|
85
|
-
puts "Capistrano v#{Capistrano::Version
|
|
119
|
+
puts "Capistrano v#{Capistrano::Version}"
|
|
86
120
|
exit
|
|
87
121
|
end
|
|
88
122
|
|
|
89
123
|
opts.on("-v", "--verbose",
|
|
90
124
|
"Be more verbose. May be given more than once."
|
|
91
|
-
)
|
|
125
|
+
) do
|
|
126
|
+
options[:verbose] ||= 0
|
|
127
|
+
options[:verbose] += 1
|
|
128
|
+
end
|
|
92
129
|
|
|
93
130
|
opts.on("-X", "--skip-system-config",
|
|
94
131
|
"Don't load the system config file (capistrano.conf)"
|
|
@@ -116,6 +153,8 @@ module Capistrano
|
|
|
116
153
|
|
|
117
154
|
option_parser.parse!(args)
|
|
118
155
|
|
|
156
|
+
coerce_variable_types!
|
|
157
|
+
|
|
119
158
|
# if no verbosity has been specified, be verbose
|
|
120
159
|
options[:verbose] = 3 if !options.has_key?(:verbose)
|
|
121
160
|
|
|
@@ -146,6 +185,7 @@ module Capistrano
|
|
|
146
185
|
%w(Capfile capfile).each do |file|
|
|
147
186
|
if File.file?(file)
|
|
148
187
|
options[:recipes] << file
|
|
188
|
+
@logger.info "Using recipes from #{File.join(current,file)}"
|
|
149
189
|
return
|
|
150
190
|
end
|
|
151
191
|
end
|
|
@@ -161,7 +201,7 @@ module Capistrano
|
|
|
161
201
|
def default_sysconf #:nodoc:
|
|
162
202
|
File.join(sysconf_directory, "capistrano.conf")
|
|
163
203
|
end
|
|
164
|
-
|
|
204
|
+
|
|
165
205
|
def default_dotfile #:nodoc:
|
|
166
206
|
File.join(home_directory, ".caprc")
|
|
167
207
|
end
|
|
@@ -171,13 +211,33 @@ module Capistrano
|
|
|
171
211
|
# appropriate location for this file in Windows.
|
|
172
212
|
ENV["SystemRoot"] || '/etc'
|
|
173
213
|
end
|
|
174
|
-
|
|
214
|
+
|
|
175
215
|
def home_directory #:nodoc:
|
|
176
216
|
ENV["HOME"] ||
|
|
177
217
|
(ENV["HOMEPATH"] && "#{ENV["HOMEDRIVE"]}#{ENV["HOMEPATH"]}") ||
|
|
178
218
|
"/"
|
|
179
219
|
end
|
|
180
220
|
|
|
221
|
+
def coerce_variable_types!
|
|
222
|
+
[:pre_vars, :vars].each do |collection|
|
|
223
|
+
options[collection].keys.each do |key|
|
|
224
|
+
options[collection][key] = coerce_variable(options[collection][key])
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def coerce_variable(value)
|
|
230
|
+
case value
|
|
231
|
+
when /^"(.*)"$/ then $1
|
|
232
|
+
when /^'(.*)'$/ then $1
|
|
233
|
+
when /^\d+$/ then value.to_i
|
|
234
|
+
when /^\d+\.\d*$/ then value.to_f
|
|
235
|
+
when "true" then true
|
|
236
|
+
when "false" then false
|
|
237
|
+
when "nil" then nil
|
|
238
|
+
else value
|
|
239
|
+
end
|
|
240
|
+
end
|
|
181
241
|
end
|
|
182
242
|
end
|
|
183
|
-
end
|
|
243
|
+
end
|