Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/tools/capistrano/lib/capistrano/cli.rb

Revision 7166, 1.8 kB (checked in by minam, 1 year ago)

Put $stdout in sync mode so that prompts are displayed correctly

Line 
1 require 'capistrano'
2 require 'capistrano/cli/execute'
3 require 'capistrano/cli/help'
4 require 'capistrano/cli/options'
5 require 'capistrano/cli/ui'
6
7 module Capistrano
8   # The CLI class encapsulates the behavior of capistrano when it is invoked
9   # as a command-line utility. This allows other programs to embed Capistrano
10   # and preserve its command-line semantics.
11   class CLI
12     # The array of (unparsed) command-line options
13     attr_reader :args
14
15     # Create a new CLI instance using the given array of command-line parameters
16     # to initialize it. By default, +ARGV+ is used, but you can specify a
17     # different set of parameters (such as when embedded cap in a program):
18     #
19     #   require 'capistrano/cli'
20     #   Capistrano::CLI.parse(%w(-vvvv -r config/deploy update_code)).execute!
21     #
22     # Note that you can also embed cap directly by creating a new Configuration
23     # instance and setting it up, but you'll often wind up duplicating logic
24     # defined in the CLI class. The above snippet, redone using the Configuration
25     # class directly, would look like:
26     #
27     #   require 'capistrano'
28     #   require 'capistrano/cli'
29     #   config = Capistrano::Configuration.new
30     #   config.logger_level = Capistrano::Logger::TRACE
31     #   config.set(:password) { Capistrano::CLI.password_prompt }
32     #   config.load "config/deploy"
33     #   config.update_code
34     #
35     # There may be times that you want/need the additional control offered by
36     # manipulating the Configuration directly, but generally interfacing with
37     # the CLI class is recommended.
38     def initialize(args)
39       @args = args.dup
40       $stdout.sync = true # so that Net::SSH prompts show up
41     end
42
43     # Mix-in the actual behavior
44     include Execute, Options, UI
45     include Help # needs to be included last, because it overrides some methods
46   end
47 end
Note: See TracBrowser for help on using the browser.