Class: MeshChat::Command::Init
- Inherits:
-
Base
- Object
- MeshChat::CLI::Input
- Base
- MeshChat::Command::Init
- Defined in:
- lib/meshchat/command/init.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
Attributes inherited from MeshChat::CLI::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
#confirm?(msg) ⇒ Boolean
26 27 28 29 30 31 |
# File 'lib/meshchat/command/init.rb', line 26 def confirm?(msg) Display.warning(msg + ' (Y/N)') response = gets response = response.chomp ['yes', 'y'].include?(response.downcase) end |
#handle ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/meshchat/command/init.rb', line 4 def handle if Settings.uid_exists? if confirm? 'uid exists, are you sure you want a new identity?' Settings.generate_uid else Display.alert 'uid generation aborted' end else Settings.generate_uid end if Settings.keys_exist? if confirm? 'keys exist, overwrite?' Settings.generate_keys else Display.alert 'key generation aborted' end else Settings.generate_keys end end |