Sha256: 8439fc498510667483f5d310a9697a516c0561bbcc75433828e809177c14f75d

Contents?: true

Size: 926 Bytes

Versions: 2

Compression:

Stored size: 926 Bytes

Contents

#!/usr/bin/env ruby

require 'bundler/setup'
require 'maxcube/network/tcp/client'
require 'maxcube/network/udp/client'

HELP_KEYS = %w[h -h help -help --help ? -?].freeze

help = ARGV.size == 1 && HELP_KEYS.include?(ARGV.first)
wrong_args = ARGV.size > 2

if help || wrong_args
  puts "Wrong number of arguments: #{ARGV.size} (expected: 0..2)" if wrong_args
  puts "USAGE: ruby #{__FILE__} [<help>|<host>] [<port>]\n" \
       "  <help> - on of these: #{HELP_KEYS}\n\n" \
       "If no arguments are given, UDP discovery is performed.\n" \
       'Otherwise, TCP client is launched (unless help command entered).'
  exit
end

if ARGV.empty?
  puts "No arguments given - performing UDP discovery ...\n" \
       "(For usage message, type one of these: #{HELP_KEYS})\n\n"
  client = MaxCube::Network::UDP::Client.new
  client.discovery
  client.close
  exit
end

client = MaxCube::Network::TCP::Client.new
client.connect(*ARGV)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
maxcube-client-0.4.1 bin/maxcube-client
maxcube-client-0.4.0 bin/maxcube-client