Class: Crossover::CLI

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

Instance Method Summary collapse

Instance Method Details

#clientObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/crossover/cli.rb', line 10

def client
  begin
    remote_host = options[:host]
    port = options[:port]
    data = options[:data] || Client.clean_data
    puts Client.post(data, remote_host, port)

  rescue Errno::ECONNREFUSED
    puts "Sorry! Connection refused by #{remote_host} on  port #{port}"

  rescue Errno::EADDRNOTAVAIL
    puts "Sorry! Can't assign requested address for #{remote_host} on port #{port}"

  rescue Interrupt
    puts "\nExiting ..."
  end
end

#serverObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/crossover/cli.rb', line 33

def server
  begin
    host = options[:host]
    port = options[:port].to_i
    logfile = options[:logfile]
    max_connections = options[:max_connections]
    @server = Server.new( port, host, max_connections, logfile, true   )
    @server.start
    @server.join

  rescue Errno::EADDRINUSE
    puts "Sorry! The port #{port} is already in use."

  rescue Errno::EACCES => e
    puts "Sorry! Ensure that you have the correct permissions as per message below:\n#{e}  "

  rescue Interrupt
    puts "\nExiting ..."
  end
end

#versionObject



56
57
58
# File 'lib/crossover/cli.rb', line 56

def version
  puts "Crossover version #{Crossover::VERSION}"
end