class Convoy::AutoOptions

Attributes

options[R]

Public Class Methods

augment(setup) click to toggle source
# File lib/convoy/auto_options.rb, line 4
def augment(setup)
    if setup.has_config_file?
        setup.add_global_option :config, "Configuration file to use for this execution", :short => :none, :long => '--config', :type => :string

        setup.add_global_command :convoy, :aliases => [] do |command|
            command.summary "Auto created utility command"
            command.description "Auto created utility command"
            command.requires_arguments false

            command.options do |opts|
                opts.opt :create_config, "Create configuration file at specified location", :short => :none, :long => '--create-config', :type => :string
                opts.opt :create_default_config, "Create a default configuration file", :short => :none, :long => '--create-default-config', :type => :boolean, :default => false
                opts.opt :update_config, "Update configuration file at specified location", :short => :none, :long => '--update-config', :type => :string
                opts.opt :update_default_config, "Update the default configuration file", :short => :none, :long => '--update-default-config', :type => :boolean, :default => false

                opts.conflict :create_config, :create_default_config, :update_config, :update_default_config
            end

            command.action do |options, arguments|
                ActionCommand::ConvoyUtilityCommand.new(setup, options, arguments).execute
            end
        end
    end
    setup.add_global_option :verbosity, 'Verbosity level of output for current execution (e.g. INFO, DEBUG)', :short => :none, :long => '--verbosity', :type => :string, :default => 'WARN'
    setup.add_global_option :error_output_format, 'The format to use when outputting errors (e.g. basic, advanced)', :short => :none, :long => '--error-output-format', :type => :string, :default => 'basic'
end
new(options) click to toggle source
# File lib/convoy/auto_options.rb, line 34
def initialize(options)
    @options = options
end

Public Instance Methods

error_formatter() click to toggle source
# File lib/convoy/auto_options.rb, line 53
def error_formatter
    error_output_format.to_sym
end
non_default_config_path() click to toggle source
# File lib/convoy/auto_options.rb, line 38
def non_default_config_path
    if options[:config_given] && File.exists?(config_path)
        config_path
    elsif !options[:config_given]
        nil
    else
        error_logger.warn "The given config file '#{options[:config]}' does not exist, falling back to default"
        nil
    end
end
verbosity() click to toggle source
# File lib/convoy/auto_options.rb, line 49
def verbosity
    error_verbosity.upcase
end

Private Instance Methods

config_path() click to toggle source
# File lib/convoy/auto_options.rb, line 59
def config_path
    File.expand_path(options[:config])
end
error_output_format() click to toggle source
# File lib/convoy/auto_options.rb, line 63
def error_output_format
    options[:error_output_format]
end
error_verbosity() click to toggle source
# File lib/convoy/auto_options.rb, line 67
def error_verbosity
    options[:verbosity]
end