Class: Capistrano::CLI

Inherits:
Object
  • Object
show all
Includes:
Execute, Help, Options, UI
Defined in:
lib/capistrano/cli.rb,
lib/capistrano/cli/ui.rb,
lib/capistrano/cli/help.rb,
lib/capistrano/cli/execute.rb,
lib/capistrano/cli/options.rb

Overview

The CLI class encapsulates the behavior of capistrano when it is invoked as a command-line utility. This allows other programs to embed Capistrano and preserve its command-line semantics.

Defined Under Namespace

Modules: Execute, Help, Options, UI

Constant Summary

Constants included from Help

Help::HEADER_LEN, Help::LINE_PADDING, Help::MIN_MAX_LEN

Instance Attribute Summary collapse

Attributes included from Options

#options

Instance Method Summary collapse

Methods included from Help

#execute_requested_actions_with_help, #explain_task, #format_text, included, #long_help, #output_columns, #task_list

Methods included from Execute

#execute!, #execute_requested_actions, #handle_error, included, #instantiate_configuration, #load_recipes, #set_pre_vars

Methods included from Options

#coerce_variable, #coerce_variable_types!, #default_dotfile, #default_sysconf, #extract_environment_variables!, #home_directory, included, #look_for_default_recipe_file!, #option_parser, #parse_options!, #sysconf_directory

Methods included from UI

included

Constructor Details

#initialize(args) ⇒ CLI

Create a new CLI instance using the given array of command-line parameters to initialize it. By default, ARGV is used, but you can specify a different set of parameters (such as when embedded cap in a program):

require 'capistrano/cli'
Capistrano::CLI.parse(%W(-vvvv -f config/deploy update_code)).execute!

Note that you can also embed cap directly by creating a new Configuration instance and setting it up, The above snippet, redone using the Configuration class directly, would look like:

require 'capistrano'
require 'capistrano/cli'
config = Capistrano::Configuration.new
config.logger.level = Capistrano::Logger::TRACE
config.set(:password) { Capistrano::CLI.password_prompt }
config.load "config/deploy"
config.update_code

There may be times that you want/need the additional control offered by manipulating the Configuration directly, but generally interfacing with the CLI class is recommended.


37
38
39
40
# File 'lib/capistrano/cli.rb', line 37

def initialize(args)
  @args = args.dup
  $stdout.sync = true # so that Net::SSH prompts show up
end

Instance Attribute Details

#argsObject (readonly)

The array of (unparsed) command-line options


13
14
15
# File 'lib/capistrano/cli.rb', line 13

def args
  @args
end