Skip to content

Commit

Permalink
Patch for ticket #50 - Capistrano::Configuration.logger options
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafa G authored and leehambley committed Jul 21, 2009
1 parent 25d1c23 commit b774827
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/capistrano/cli/execute.rb
Expand Up @@ -21,7 +21,7 @@ def execute
#
# Returns the Configuration instance used, if successful.
def execute!
config = instantiate_configuration
config = instantiate_configuration(options)
config.debug = options[:debug]
config.dry_run = options[:dry_run]
config.logger.level = options[:verbose]
Expand Down Expand Up @@ -66,8 +66,8 @@ def load_recipes(config) #:nodoc:

# Primarily useful for testing, but subclasses of CLI could conceivably
# override this method to return a Configuration subclass or replacement.
def instantiate_configuration #:nodoc:
Capistrano::Configuration.new
def instantiate_configuration(options={}) #:nodoc:
Capistrano::Configuration.new(options)
end

def handle_error(error) #:nodoc:
Expand All @@ -81,4 +81,4 @@ def handle_error(error) #:nodoc:
end
end
end
end
end
5 changes: 4 additions & 1 deletion lib/capistrano/cli/help.txt
Expand Up @@ -28,6 +28,9 @@ The following options are understood:
<%= color '-h, --help', :bold %>
Shows a brief summary of these options and exits.

<%= color '-l, --logger [STDERR|STDOUT|file]', :bold %>
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.

<%= color '-n, --dry-run', :bold %>
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.

Expand Down Expand Up @@ -72,4 +75,4 @@ The following options are understood:
Execute tasks against this comma-separated list of host, but only if the host has the proper role for the task.

<%= color 'ROLES', :bold %>
Execute tasks against this comma-separated list of roles. Hosts which do not have the right roles will be skipped.
Execute tasks against this comma-separated list of roles. Hosts which do not have the right roles will be skipped.
13 changes: 13 additions & 0 deletions lib/capistrano/cli/options.rb
Expand Up @@ -54,6 +54,19 @@ def option_parser #:nodoc:
exit
end

opts.on("-l", "--logger [STDERR|STDOUT|file]",
"Choose logger method. STDERR used by default."
) do |value|
options[:output] = if value.nil? || value.upcase == 'STDERR'
# Using default logger.
nil
elsif value.upcase == 'STDOUT'
$stdout
else
value
end
end

opts.on("-n", "--dry-run",
"Prints out commands without running them."
) { |value| options[:dry_run] = true }
Expand Down
4 changes: 2 additions & 2 deletions lib/capistrano/configuration.rb
Expand Up @@ -21,10 +21,10 @@ class Configuration
# The logger instance defined for this configuration.
attr_accessor :debug, :logger, :dry_run

def initialize #:nodoc:
def initialize(options={}) #:nodoc:
@debug = false
@dry_run = false
@logger = Logger.new
@logger = Logger.new(options)
end

# make the DSL easier to read when using lazy evaluation via lambdas
Expand Down

0 comments on commit b774827

Please sign in to comment.