#!/usr/bin/env ruby require 'optparse' require File.expand_path('client', File.join(File.dirname(__FILE__), '..', 'lib')) options = {} cmd_args = OptionParser.new do |opts| opts.banner = 'Usage: proxylocal [options] [PORT]' opts.on('-s', '--server SERVER') do |s| options[:server_host], options[:server_port] = s.split(':') end opts.on('--[no-]tls', 'Use TLS') do |tls| options[:tls] = tls end opts.on('-v', '--[no-]verbose', 'Run verbosely') do |v| options[:verbose] = v end opts.on_tail('-h', '--help', 'Show this message') do puts opts exit end opts.on_tail("--version", "Show version") do puts ProxyLocal::VERSION exit end end.parse! options[:local_port] = cmd_args[0] default_options = { :server_host => 'proxylocal.com', :server_port => '8282', :local_port => '80', :tls => true, :verbose => false } options = default_options.merge(options.reject { |k, v| v.nil? }) ProxyLocal::Client.run(options)