def parse_args
      options = {}
      options[:agent_name] = ARGV[0]
      options[:options] = { :secure => true }
      options[:quiet] = false
      fail('No agent specified on the command line', print_usage = true) if options[:agent_name].nil?

      opts = OptionParser.new do |opts|
        parse_common(opts, options)
        parse_other_args(opts, options)

        opts.on('-r', '--root-dir DIR') do |d|
          # Allow for more than one
          if options[:root_dir]
            options[:root_dir] = [options[:root_dir]] unless options[:root_dir].is_a?(Array)
            options[:root_dir] << d
          else
            options[:root_dir] = d
          end
        end

        opts.on('-c', '--cfg-dir DIR') do |d|
          options[:cfg_dir] = d
        end

        opts.on('-z', '--pid-dir DIR') do |d|
          options[:pid_dir] = d
        end

        opts.on('--monit') do
          options[:monit] = true
        end

        opts.on('--http-proxy PROXY') do |proxy|
          options[:http_proxy] = proxy
        end

        opts.on('--http-no-proxy NOPROXY') do |no_proxy|
          options[:http_no_proxy] = no_proxy
        end

        opts.on('--time-to-live SEC') do |sec|
          options[:time_to_live] = sec.to_i
        end

        opts.on('--retry-timeout SEC') do |sec|
          options[:retry_timeout] = sec.to_i
        end

        opts.on('--retry-interval SEC') do |sec|
          options[:retry_interval] = sec.to_i
        end

        opts.on('--check-interval SEC') do |sec|
          options[:check_interval] = sec.to_i
        end

        opts.on('--ping-interval SEC') do |sec|
          options[:ping_interval] = sec.to_i
        end

        opts.on('--reconnect-interval SEC') do |sec|
          options[:reconnect_interval] = sec.to_i
        end

        opts.on('--grace-timeout SEC') do |sec|
          options[:grace_timeout] = sec.to_i
        end

        opts.on('--[no-]dup-check') do |b|
          options[:dup_check] = b
        end

        opts.on('-f', '--fiber-pool-size N') do |n|
          options[:fiber_pool_size] = n.to_i
        end

        opts.on('--prefetch COUNT') do |count|
          options[:prefetch] = count.to_i
        end

        opts.on("-a", "--api-url URL") do |url|
          options[:api_url] = url
        end

        opts.on('-A', '--account ID') do |id|
          options[:account_id] = id.to_i
        end

        opts.on('-s', '--shard ID') do |id|
          options[:shard_id] = id.to_i
        end

        opts.on('-m', '--mode MODE') do |mode|
          options[:mode] = mode
        end

        opts.on('-b', '--heartbeat SEC') do |sec|
          options[:heartbeat] = sec.to_i
        end

        opts.on('--airbrake-endpoint URL') do |url|
          options[:airbrake_endpoint] = url
        end

        opts.on('--airbrake-api-key KEY') do |key|
          options[:airbrake_api_key] = key
        end

        opts.on('-o', '--options OPT') do |e|
          fail("Invalid option definition #{e}' (use '=' to separate name and value)") unless e.include?('=')
          key, val = e.split(/=/)
          options[:options][key.gsub('-', '_').to_sym] = val
        end

        opts.on('-Q', '--quiet') do
          options[:quiet] = true
        end

        opts.on_tail('--help') do
          puts Usage.scan(__FILE__)
          exit
        end
      end
      begin
        opts.parse!(ARGV)
      rescue Exception => e
        exit 0 if e.is_a?(SystemExit)
        fail(e.message, print_usage = true)
      end
      resolve_identity(options)
      options
    end
def parse_args
      options = {}
      options[:agent_name] = ARGV[0]
      options[:options] = { :secure => true }
      options[:quiet] = false
      fail('No agent specified on the command line', print_usage = true) if options[:agent_name].nil?

      opts = OptionParser.new do |opts|
        parse_common(opts, options)
        parse_other_args(opts, options)

        opts.on('-r', '--root-dir DIR') do |d|
          # Allow for more than one
          if options[:root_dir]
            options[:root_dir] = [options[:root_dir]] unless options[:root_dir].is_a?(Array)
            options[:root_dir] << d
          else
            options[:root_dir] = d
          end
        end

        opts.on('-c', '--cfg-dir DIR') do |d|
          options[:cfg_dir] = d
        end

        opts.on('-z', '--pid-dir DIR') do |d|
          options[:pid_dir] = d
        end

        opts.on('--monit') do
          options[:monit] = true
        end

        opts.on('--http-proxy PROXY') do |proxy|
          options[:http_proxy] = proxy
        end

        opts.on('--http-no-proxy NOPROXY') do |no_proxy|
          options[:http_no_proxy] = no_proxy
        end

        opts.on('--time-to-live SEC') do |sec|
          options[:time_to_live] = sec.to_i
        end

        opts.on('--retry-timeout SEC') do |sec|
          options[:retry_timeout] = sec.to_i
        end

        opts.on('--retry-interval SEC') do |sec|
          options[:retry_interval] = sec.to_i
        end

        opts.on('--check-interval SEC') do |sec|
          options[:check_interval] = sec.to_i
        end

        opts.on('--ping-interval SEC') do |sec|
          options[:ping_interval] = sec.to_i
        end

        opts.on('--reconnect-interval SEC') do |sec|
          options[:reconnect_interval] = sec.to_i
        end

        opts.on('--grace-timeout SEC') do |sec|
          options[:grace_timeout] = sec.to_i
        end

        opts.on('--[no-]dup-check') do |b|
          options[:dup_check] = b
        end

        opts.on('-f', '--fiber-pool-size N') do |n|
          options[:fiber_pool_size] = n.to_i
        end

        opts.on('--prefetch COUNT') do |count|
          options[:prefetch] = count.to_i
        end

        opts.on("-a", "--api-url URL") do |url|
          options[:api_url] = url
        end

        opts.on('-A', '--account ID') do |id|
          options[:account_id] = id.to_i
        end

        opts.on('-s', '--shard ID') do |id|
          options[:shard_id] = id.to_i
        end

        opts.on('-m', '--mode MODE') do |mode|
          options[:mode] = mode
        end

        opts.on('-b', '--heartbeat SEC') do |sec|
          options[:heartbeat] = sec.to_i
        end

        opts.on('--airbrake-endpoint URL') do |url|
          options[:airbrake_endpoint] = url
        end

        opts.on('--airbrake-api-key KEY') do |key|
          options[:airbrake_api_key] = key
        end

        opts.on('-o', '--options OPT') do |e|
          fail("Invalid option definition #{e}' (use '=' to separate name and value)") unless e.include?('=')
          key, val = e.split(/=/)
          options[:options][key.gsub('-', '_').to_sym] = val
        end

        opts.on('-Q', '--quiet') do
          options[:quiet] = true
        end

        opts.on_tail('--help') do
          puts Usage.scan(__FILE__)
          exit
        end
      end
      begin
        opts.parse!(ARGV)
      rescue Exception => e
        exit 0 if e.is_a?(SystemExit)
        fail(e.message, print_usage = true)
      end
      resolve_identity(options)
      options
    end
Create options hash from command line arguments

 === Return
 options(Hash):: Parsed options