Class: MeshChat::CLI::Import
- Defined in:
- lib/meshchat/cli/import.rb
Constant Summary
Constants inherited from Command
Command::ADD, Command::CHAT, Command::CONFIG, Command::CONNECT, Command::DISPLAY, Command::EXIT, Command::EXPORT, Command::IDENTITY, Command::IMPORT, Command::INIT, Command::IRB, Command::LISTEN, Command::PING, Command::PING_ALL, Command::QUIT, Command::REMOVE, Command::RM, Command::SERVER, Command::SERVERS, Command::SET, Command::SHARE, Command::STOP_LISTENING, Command::WHO
Constants inherited from Input
MeshChat::CLI::Input::COMMAND, MeshChat::CLI::Input::WHISPER
Instance Attribute Summary
Attributes inherited from Command
Attributes inherited from 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
#command_valid? ⇒ Boolean
28 29 30 |
# File 'lib/meshchat/cli/import.rb', line 28 def command_valid? filename.present? end |
#filename ⇒ Object
32 33 34 |
# File 'lib/meshchat/cli/import.rb', line 32 def filename sub_command end |
#handle ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/meshchat/cli/import.rb', line 4 def handle if command_valid? node = Models::Entry.import_from_file(filename) if node.valid? && node.persisted? Display.success "#{node.alias_name} successfully imported" # send the server list to this new node Net::Client.send( node: node, message: Message::NodeList.new ) else Display.alert "#{node.alias_name} is invalid" Display.alert node.errors..join("\n") end else Display.alert usage end end |
#usage ⇒ Object
24 25 26 |
# File 'lib/meshchat/cli/import.rb', line 24 def usage 'Usage: /import {filename}' end |