Class: DnsMadeEasy::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/dnsmadeeasy/runner.rb

Constant Summary collapse

SUPPORTED_FORMATS =
%w(json json_pretty yaml pp).freeze
SUPPORTED_FORMAT_FLAGS =
SUPPORTED_FORMATS.map { |f| "--#{f}" }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv = nil) ⇒ Runner



19
20
21
22
# File 'lib/dnsmadeeasy/runner.rb', line 19

def initialize(argv = nil)
  self.argv = argv || ARGV.dup
  self.format = process_flags_format
end

Instance Attribute Details

#argvObject

Returns the value of attribute argv.



17
18
19
# File 'lib/dnsmadeeasy/runner.rb', line 17

def argv
  @argv
end

#formatObject

Returns the value of attribute format.



17
18
19
# File 'lib/dnsmadeeasy/runner.rb', line 17

def format
  @format
end

#operationObject

Returns the value of attribute operation.



17
18
19
# File 'lib/dnsmadeeasy/runner.rb', line 17

def operation
  @operation
end

Instance Method Details

#execute!Object



24
25
26
27
28
29
30
31
32
# File 'lib/dnsmadeeasy/runner.rb', line 24

def execute!
  if argv.empty? || argv.empty?
    print_help_message
  else
    configure_authentication
    self.operation = argv.shift.to_sym
    exit call_through_client(operation)
  end
end