bin/proxylocal in proxylocal-0.0.4 vs bin/proxylocal in proxylocal-0.0.5
- old
+ new
@@ -1,26 +1,46 @@
#!/usr/bin/env ruby
require 'optparse'
require File.expand_path('client', File.join(File.dirname(__FILE__), '..', 'lib'))
-server_host = nil
-server_port = nil
+options = {}
-options = OptionParser.new do |o|
- o.banner = "Usage: localtunnel [options] PORT"
- o.on('-s', '--server SERVER', 'default proxylocal.com') do |server|
- server_host, server_port = server.split(':')
+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
- o.on('-h', "--help", "show this help") { puts o; exit }
-end
-args = options.parse!
+ opts.on('--[no-]tls', 'Use TLS') do |tls|
+ options[:tls] = tls
+ end
-server_host ||= 'proxylocal.com'
-server_port ||= '8282'
+ opts.on('-v', '--[no-]verbose', 'Run verbosely') do |v|
+ options[:verbose] = v
+ end
-local_port = args[0] || 80
+ opts.on_tail('-h', '--help', 'Show this message') do
+ puts opts
+ exit
+ end
-ProxyLocal::Client.run(:server_host => server_host,
- :server_port => server_port,
- :local_port => local_port)
+ 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)