Class: ADAssault::CLI::DNS::DUZDU::BaseAction

Inherits:
Object
  • Object
show all
Defined in:
lib/adassault/cli/dns/duzdu/baseaction.rb

Overview

stuff common to all duzdu’s sub-commands

Since:

  • 0.0.1

Direct Known Subclasses

Add, Check, Delete, Get, Replace

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ BaseAction

Returns a new instance of BaseAction.

Since:

  • 0.0.1



16
17
18
19
20
# File 'lib/adassault/cli/dns/duzdu/baseaction.rb', line 16

def initialize(options)
  parent_options = options.dig(GLI::Command::PARENT, GLI::Command::PARENT)
  dns_opts = parent_options[:nameserver].nil? ? nil : { nameserver: [parent_options[:nameserver]] }
  @duz = ADAssault::DNS::DUZDU.new(parent_options[:domain], dns_opts)
end

Class Method Details

.argumentsObject

Raises:

  • (NotImplementedError)

Since:

  • 0.0.1



39
40
41
# File 'lib/adassault/cli/dns/duzdu/baseaction.rb', line 39

def arguments
  raise NotImplementedError, 'Sub-class must implement this method'
end

.command_nameObject

Since:

  • 0.0.1



27
28
29
# File 'lib/adassault/cli/dns/duzdu/baseaction.rb', line 27

def command_name
  name.split('::').last.downcase
end

.descriptionObject

Raises:

  • (NotImplementedError)

Since:

  • 0.0.1



31
32
33
# File 'lib/adassault/cli/dns/duzdu/baseaction.rb', line 31

def description
  raise NotImplementedError, 'Sub-class must implement this method'
end

.long_descriptionObject

Raises:

  • (NotImplementedError)

Since:

  • 0.0.1



35
36
37
# File 'lib/adassault/cli/dns/duzdu/baseaction.rb', line 35

def long_description
  raise NotImplementedError, 'Sub-class must implement this method'
end

.register(parent_command) ⇒ Object

Since:

  • 0.0.1



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/adassault/cli/dns/duzdu/baseaction.rb', line 43

def register(parent_command)
  parent_command.desc description
  parent_command.long_desc long_description unless long_description.empty?
  arguments.each { |argument| parent_command.arg argument } # won't register args if arguments is empty
  parent_command.command command_name.to_sym do |cmd|
    cmd.action do |_global_options, options, args|
      action = new(options)
      action.run(args)
    end
  end
end

Instance Method Details

#run(_args) ⇒ Object

Raises:

  • (NotImplementedError)

Since:

  • 0.0.1



22
23
24
# File 'lib/adassault/cli/dns/duzdu/baseaction.rb', line 22

def run(_args)
  raise NotImplementedError, 'Sub-class must implement this method'
end