Sha256: a9a89bf361d7587717c3d4886ff5e47be1ffa15239818e3274ca455dc66dd3ff

Contents?: true

Size: 1.58 KB

Versions: 4

Compression:

Stored size: 1.58 KB

Contents

require 'optparse'

def default_options
  {
    "server_host" => 'p45.eu',
    "server_port" => "8282",
    "local_host" => '127.0.0.1',
    "tls" => false,
    "verbose" => false,
    "version" => Envoy::VERSION,
    "delay" => 1,
    "dir" => "."
  }
end

def parse_options
  options = default_options
  OptionParser.new do |op|
    op.banner = "Usage: #{$0} [options] [[HOST:]PORT]"
    op.on "--host HOST", "Allocate this domain label on the proxy" do |v|
      options["hosts"] ||= []
      options["hosts"] << v
    end
    op.on "-k", "--key KEY" do |v|
      options["key"] = v
    end
    op.on "-t", "--[no-]tls", "Encrypt communications with the envoy server" do |v|
      options["tls"] = v
    end
    op.on "-s", "--server SERVER", "Specify envoy/proxylocal server" do |v|
      host, port = v.split(":")
      options["server_host"] = host
      options["server_port"] ||= port
    end
    op.on "-v", "--[no-]verbose", "Be noisy about what's happening" do |v|
      options["verbose"] = v
    end
    op.on "--no-log", "Don't show HTTP log" do |v|
      options["log"] = false
    end
    op.on "l", "--log FILE", "Write HTTP log to this file" do |v|
      options["log"] = v
    end
    op.on "-h", "--help", "Show this message" do
      puts op
      exit
    end
    op.on "--version" do
      puts Envoy::VERSION
      exit
    end
    op.parse!
    case ARGV[0]
    when /^(\d+)$/
      options["local_port"] = $1
    when /^(\[[^\]+]\]|[^:]+):(\d+)$/x
      options["local_host"] = $1
      options["local_port"] = $2
    when /^(.*)$/
      options["local_host"] = $1
    end
  end
  options
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
envoy-proxy-0.1.5 lib/envoy/client/option_parser.rb
envoy-proxy-0.1.4 lib/envoy/client/option_parser.rb
envoy-proxy-0.1.3 lib/envoy/client/option_parser.rb
envoy-proxy-0.1.2 lib/envoy/client/option_parser.rb