Class: WifiWand::Commands::Nameservers

Inherits:
Base
  • Object
show all
Defined in:
lib/wifi_wand/commands/nameservers.rb

Constant Summary collapse

RESERVED_SUBCOMMANDS =
%w[get clear].freeze

Constants inherited from Base

Base::DEFAULT_INVOCATION_OPTIONS

Instance Attribute Summary

Attributes inherited from Base

#cli, #metadata

Instance Method Summary collapse

Methods inherited from Base

#aliases, allow_invocation_options, allowed_invocation_options, #bind, binding_sources, binds, command_metadata, declared_metadata, #help_text, #initialize, #validate_options

Constructor Details

This class inherits a constructor from WifiWand::Commands::Base

Instance Method Details

#call(*args) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/wifi_wand/commands/nameservers.rb', line 20

def call(*args)
  subcommand = subcommand_for(args)

  case subcommand
  when :get
    current_nameservers = model.nameservers
    output_support.handle_output(current_nameservers,
      human_readable_string_producer(current_nameservers))
  when :clear
    model.set_nameservers(:clear)
    output_support.handle_output([], -> { 'Nameservers cleared.' })
  when :put
    nameservers = model.set_nameservers(args)
    output_support.handle_output(nameservers, -> { "Nameservers set to: #{nameservers.join(', ')}" })
  end
end