Class: Hokaido::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/hokaido/cli.rb

Instance Method Summary collapse

Instance Method Details

#broadcast(command = ENV['SHELL']) ⇒ Object



14
15
16
# File 'lib/hokaido/cli.rb', line 14

def broadcast(command = ENV['SHELL'])
  Hokaido::Broadcast::Command.run command, *options.values_at(:host, :port)
end

#serverObject



19
20
21
22
23
24
25
# File 'lib/hokaido/cli.rb', line 19

def server
  server = Server.run(*options.values_at(:host, :port))
rescue Interrupt
  exit
ensure
  server.terminate if server
end

#versionObject



42
43
44
# File 'lib/hokaido/cli.rb', line 42

def version
  say Hokaido::VERSION, :cyan
end

#watchObject



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/hokaido/cli.rb', line 28

def watch
  server = TCPSocket.open(*options.values_at(:host, :port))
  server.puts 'watch'

  while chunk = server.readpartial(4096)
    $stdout.write chunk
  end
rescue Interrupt, EOFError, Errno::EIO
  # do nothing
ensure
  server.close if server
end