class Crossover::CLI

Public Instance Methods

client() click to toggle source
# 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
server() click to toggle source
# 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
version() click to toggle source
# File lib/crossover/cli.rb, line 56
def version
  puts "Crossover version #{Crossover::VERSION}"
end