Class: MeshChat::Command::Config

Inherits:
Base show all
Defined in:
lib/meshchat/command/config.rb

Constant Summary

Constants inherited from Base

Base::ADD, Base::CHAT, Base::CONFIG, Base::CONNECT, Base::DISPLAY, Base::EXIT, Base::EXPORT, Base::IDENTITY, Base::IMPORT, Base::INIT, Base::IRB, Base::LISTEN, Base::PING, Base::PING_ALL, Base::QUIT, Base::REMOVE, Base::RM, Base::SERVER, Base::SERVERS, Base::SET, Base::SHARE, Base::STOP_LISTENING, Base::WHO

Constants inherited from MeshChat::CLI::Input

MeshChat::CLI::Input::COMMAND, MeshChat::CLI::Input::WHISPER

Instance Attribute Summary

Attributes inherited from Base

#_input

Attributes inherited from MeshChat::CLI::Input

#_input

Instance Method Summary collapse

Methods inherited from MeshChat::CLI::Input

create, #initialize, is_command, is_whisper?

Constructor Details

This class inherits a constructor from MeshChat::CLI::Input

Instance Method Details

#config_set_argsObject



21
22
23
# File 'lib/meshchat/command/config.rb', line 21

def config_set_args
  command_args[2..3]
end

#handleObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/meshchat/command/config.rb', line 4

def handle
  case sub_command
  when SET
    if is_valid_set_command?
      key, value = config_set_args

      Display.info Settings.set(key, with: value)
    else
      Display.alert 'set requires a key and a value'
    end
  when DISPLAY
    Display.info Settings.display
  else
    Display.alert 'config command not implemented...'
  end
end

#is_valid_set_command?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/meshchat/command/config.rb', line 25

def is_valid_set_command?
  sub_command == SET && command_args.length == 4
end