lib/capistrano/cli/options.rb
# Return an OptionParser instance that defines the acceptable command
# line switches for Capistrano, and what their corresponding behaviors
# are.
Return an OptionParser instance that defines the acceptable command
line switches for Capistrano, and what their corresponding behaviors
are.
Return an OptionParser instance that defines the acceptable command line switches for Capistrano and what their corresponding behaviors are .
def option_parser 
        @logger = Logger.new
        @option_parser ||= OptionParser.new do |opts|
          opts.banner = "Usage: #{File.basename($0)} [options] action ..."
          opts.on("-d", "--debug",
            "Prompts before each remote command execution."
          ) { |value| options[:debug] = true }
          opts.on("-e", "--explain TASK",
            "Displays help (if available) for the task."
          ) { |value| options[:explain] = value }
          opts.on("-F", "--default-config",
            "Always use default config, even with -f."
          ) { options[:default_config] = true }
          opts.on("-f", "--file FILE",
            "A recipe file to load. May be given more than once."
          ) { |value| options[:recipes] << value }
          opts.on("-H", "--long-help", "Explain these options and environment variables.") do
            long_help
            exit
          end
          opts.on("-h", "--help", "Display this help message.") do
            puts opts
            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'
																 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 }
          opts.on("-p", "--password",
            "Immediately prompt for the password."
          ) { options[:password] = nil }
          opts.on("-q", "--quiet",
            "Make the output as quiet as possible."
          ) { options[:verbose] = 0 }
          opts.on("-r", "--preserve-roles",
            "Preserve task roles"
          ) { options[:preserve_roles] = true }
          opts.on("-S", "--set-before NAME=VALUE",
            "Set a variable before the recipes are loaded."
          ) do |pair|
            name, value = pair.split(/=/, 2)
            options[:pre_vars][name.to_sym] = value
          end
          opts.on("-s", "--set NAME=VALUE",
            "Set a variable after the recipes are loaded."
          ) do |pair|
            name, value = pair.split(/=/, 2)
            options[:vars][name.to_sym] = value
          end
          opts.on("-T", "--tasks [PATTERN]",
            "List all tasks (matching optional PATTERN) in the loaded recipe files."
          ) do |value|
            options[:tasks] = if value
              value
            else
              true
            end
            options[:verbose] ||= 0
          end
          opts.on("-t", "--tool",
            "Abbreviates the output of -T for tool integration."
          ) { options[:tool] = true }
          opts.on("-V", "--version",
            "Display the Capistrano version, and exit."
          ) do
            require 'capistrano/version'
            puts "Capistrano v#{Capistrano::Version}"
            exit
          end
          opts.on("-v", "--verbose",
            "Be more verbose. May be given more than once."
          ) do
            options[:verbose] ||= 0
            options[:verbose] += 1
          end
          opts.on("-X", "--skip-system-config",
            "Don't load the system config file (capistrano.conf)"
          ) { options.delete(:sysconf) }
          opts.on("-x", "--skip-user-config",
            "Don't load the user config file (.caprc)"
          ) { options.delete(:dotfile) }
        end
      end
def option_parser @logger = Logger . new @option_parser ||= OptionParser . new do | opts | opts . banner = "Usage: #{File.basename($0)} [options] action ..." opts . on ( "-d" , "--debug" , "Prompts before each remote command execution." ) { | value | options [ :debug ] = true } opts . on ( "-e" , "--explain TASK" , "Displays help (if available) for the task." ) { | value | options [ :explain ] = value } opts . on ( "-F" , "--default-config" , "Always use default config, even with -f." ) { options [ :default_config ] = true } opts . on ( "-f" , "--file FILE" , "A recipe file to load. May be given more than once." ) { | value | options [ :recipes ] << value } opts . on ( "-H" , "--long-help" , "Explain these options and environment variables." ) do long_help exit end opts . on ( "-h" , "--help" , "Display this help message." ) do puts opts 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' 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 } opts . on ( "-p" , "--password" , "Immediately prompt for the password." ) { options [ :password ] = nil } opts . on ( "-q" , "--quiet" , "Make the output as quiet as possible." ) { options [ :verbose ] = 0 } opts . on ( "-r" , "--preserve-roles" , "Preserve task roles" ) { options [ :preserve_roles ] = true } opts . on ( "-S" , "--set-before NAME=VALUE" , "Set a variable before the recipes are loaded." ) do | pair | name , value = pair . split ( / = / , 2 ) options [ :pre_vars ] [ name . to_sym ] = value end opts . on ( "-s" , "--set NAME=VALUE" , "Set a variable after the recipes are loaded." ) do | pair | name , value = pair . split ( / = / , 2 ) options [ :vars ] [ name . to_sym ] = value end opts . on ( "-T" , "--tasks [PATTERN]" , "List all tasks (matching optional PATTERN) in the loaded recipe files." ) do | value | options [ :tasks ] = if value value else true end options [ :verbose ] ||= 0 end opts . on ( "-t" , "--tool" , "Abbreviates the output of -T for tool integration." ) { options [ :tool ] = true } opts . on ( "-V" , "--version" , "Display the Capistrano version, and exit." ) do require 'capistrano/version' puts "Capistrano v#{Capistrano::Version}" exit end opts . on ( "-v" , "--verbose" , "Be more verbose. May be given more than once." ) do options [ :verbose ] ||= 0 options [ :verbose ] += 1 end opts . on ( "-X" , "--skip-system-config" , "Don't load the system config file (capistrano.conf)" ) { options . delete ( :sysconf ) } opts . on ( "-x" , "--skip-user-config" , "Don't load the user config file (.caprc)" ) { options . delete ( :dotfile ) } end end
Return an OptionParser instance that defines the acceptable command
line switches for Capistrano, and what their corresponding behaviors
are.
Return an OptionParser instance that defines the acceptable command line switches for Capistrano and what their corresponding behaviors are .
#:nodoc: # Using default logger.