Class: MeshChat::CLI::Config

Inherits:
Command show all
Defined in:
lib/meshchat/cli/config.rb

Constant Summary

Constants inherited from Command

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

Constants inherited from Input

Input::COMMAND, Input::WHISPER

Instance Attribute Summary

Attributes inherited from Command

#_input

Attributes inherited from Input

#_input

Instance Method Summary collapse

Methods inherited from 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/cli/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/cli/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/cli/config.rb', line 25

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