Class: Dynamic53::CLI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



6
7
8
9
# File 'lib/dynamic_53/cli.rb', line 6

def initialize(argv)
  @argv = argv
  @options = {}
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/dynamic_53/cli.rb', line 4

def options
  @options
end

Instance Method Details

#parse_options!Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/dynamic_53/cli.rb', line 11

def parse_options!
  parser = options_parser
  parser.parse!(@argv)

  unless options[:hostname] && options[:zone]
    $stderr.puts "Error: both zone and hostname arguments must be provided."
    $stderr.puts parser.banner
    exit(1)
  end
end

#runObject



22
23
24
25
# File 'lib/dynamic_53/cli.rb', line 22

def run
  parse_options!
  Dynamic53.new(options.delete(:zone), options.delete(:hostname), options).update
end