Class: Senedsa::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/senedsa/cli.rb

Constant Summary collapse

ID =
File.basename($PROGRAM_NAME).to_sym
DEFAULT_CONFIG_FILE =
File.join(ENV['HOME'],"/.#{ID}/config")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments) ⇒ CLI

Returns a new instance of CLI.



15
16
17
18
19
# File 'lib/senedsa/cli.rb', line 15

def initialize(arguments)
  @arguments = arguments
  @cli_options = { :debug => false }
  @options = {}
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#runObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/senedsa/cli.rb', line 21

def run
  begin
    parsed_options?
    config_options?
    arguments_valid?
    options_valid?
    process_options
    process_arguments
    process_command
  rescue ArgumentError, OptionParser::MissingArgument, SendNsca::ConfigurationError => e
    output_message e.message, 1
  end
end