class QuickAndRuby::Proxy::ArgParser
service parse proxy exe argv based on standard OptionParser
Attributes
argv[R]
options[R]
Public Class Methods
new(argv)
click to toggle source
# File lib/quick_and_ruby/proxy/arg_parser.rb, line 11 def initialize(argv) @argv = argv @options = { verbose: false, bind: '0.0.0.0', port: 8080 } end
Public Instance Methods
parse()
click to toggle source
# File lib/quick_and_ruby/proxy/arg_parser.rb, line 18 def parse options_parser.parse!(argv) options end
Private Instance Methods
options_parser()
click to toggle source
# File lib/quick_and_ruby/proxy/arg_parser.rb, line 27 def options_parser @options_parser ||= OptionParser.new do |opts| opts.banner = 'Usage: proxy [options]' opts.separator '' opts.separator 'Options:' opts.on('-v', '--[no-]verbose', 'Run verbosely') do |v| options[:verbose] = v end opts.on('-u', '--user USER:PASSWORD', 'specify USER') do |user| options[:user] = user end opts.on('-H', '--proxy-host HOST', 'specify proxy HOST to use') do |host| options[:proxy_host] = host end opts.on('-P', '--proxy-port PORT', 'specify proxy PORT to use') do |port| options[:proxy_port] = port end opts.on('-b', '--bind IP', 'specify IP to bind on') do |ip| options[:bind] = ip end opts.on('-p', '--port PORT', 'specify PORT to listen on') do |port| options[:port] = port end opts.on_tail('-h', '--help', 'Show this message') do puts opts exit end opts.on_tail('--version', 'Show version') do puts ::QuickAndRuby::VERSION exit end end end