Class: Del::CLI
- Inherits:
-
Thor
- Object
- Thor
- Del::CLI
- Defined in:
- lib/del/cli.rb
Constant Summary collapse
- DEFAULT_RC =
Pathname.new(Dir.home).join('.delrc')
Instance Method Summary collapse
- #console(startup_file = nil) ⇒ Object
- #message(jid, message) ⇒ Object
- #server(startup_file = nil) ⇒ Object
- #setup ⇒ Object
- #status(status, message = nil) ⇒ Object
- #users ⇒ Object
- #version ⇒ Object
- #whoami ⇒ Object
- #whois(jid) ⇒ Object
Instance Method Details
#console(startup_file = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/del/cli.rb', line 25 def console(startup_file = nil) require 'irb' Del.start(load_settings(start_server: false, startup_file: startup_file)) ARGV.clear IRB.start rescue Errno::ENOENT => error say error., :red say "run 'del setup'", :yellow end |
#message(jid, message) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/del/cli.rb', line 37 def (jid, ) SendMessage.new( self, socket_file: [:socket_file] ).run(jid, ) end |
#server(startup_file = nil) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/del/cli.rb', line 15 def server(startup_file = nil) Del.start(load_settings(start_server: true, startup_file: startup_file)) rescue Psych::DisallowedClass => error say error., :red rescue Errno::ENOENT => error say error., :red say "run 'del setup'", :yellow end |
#setup ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/del/cli.rb', line 81 def setup yaml = YAML.dump(new_settings) IO.write([:configuration_file], yaml) File.chmod(0o600, [:configuration_file]) say '' say "Configuration saved to: #{[:configuration_file]}", :green end |
#status(status, message = nil) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/del/cli.rb', line 45 def status(status, = nil) socket = SocketMessage.new(self, socket_file: [:socket_file]) socket.deliver(command: :change_status, status: status, message: ) say(socket.listen, :green) ensure socket.close end |
#users ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/del/cli.rb', line 72 def users socket = SocketMessage.new(self, socket_file: [:socket_file]) socket.deliver(command: :users) say(socket.listen, :green) ensure socket.close end |
#version ⇒ Object
90 91 92 |
# File 'lib/del/cli.rb', line 90 def version say Del::VERSION, :green end |
#whoami ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/del/cli.rb', line 54 def whoami socket = SocketMessage.new(self, socket_file: [:socket_file]) socket.deliver(command: :whoami) say(socket.listen, :green) ensure socket.close end |
#whois(jid) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/del/cli.rb', line 63 def whois(jid) socket = SocketMessage.new(self, socket_file: [:socket_file]) socket.deliver(command: :whois, q: jid) say(socket.listen, :green) ensure socket.close end |