class YARD::CLI::Server

def optparse(*args)

def optparse(*args)
  opts = OptionParser.new
  opts.banner = 'Usage: yard server [options] [[library yardoc_file] ...]'
  opts.separator ''
  opts.separator 'Example: yard server -m yard .yardoc ruby-core ../ruby/.yardoc'
  opts.separator 'The above example serves documentation for YARD and Ruby-core'
  opts.separator ''
  opts.separator 'If no library/yardoc_file is specified, the server uses'
  opts.separator 'the name of the current directory and `.yardoc` respectively'
  opts.separator ''
  opts.separator "General Options:"
  opts.on('-m', '--multi-library', 'Serves documentation for multiple libraries') do
    options[:single_library] = false
  end
  opts.on('-c', '--cache', 'Caches all documentation to document root (see --docroot)') do
    options[:caching] = true
  end
  opts.on('-r', '--reload', 'Reparses the library code on each request') do
    options[:incremental] = true
  end
  opts.on('-g', '--gems', 'Serves documentation for installed gems') do
    add_gems
  end
  opts.on('-G', '--gemfile [GEMFILE]',
          'Serves documentation for gems from Gemfile') do |gemfile|
    add_gems_from_gemfile(gemfile)
  end
  opts.on('-t', '--template-path PATH',
          'The template path to look for templates in. (used with -t).') do |path|
    template_paths << path
  end
  opts.separator ''
  opts.separator "Web Server Options:"
  opts.on('-d', '--daemon', 'Daemonizes the server process') do
    server_options[:daemonize] = true
  end
  opts.on('-B HOST', '--bind', 'The host address to bind to') do |host|
    server_options[:Host] = host.to_s
  end
  opts.on('-p PORT', '--port', 'Serves documentation on PORT') do |port|
    server_options[:Port] = port.to_i
  end
  opts.on('--docroot DOCROOT', 'Uses DOCROOT as document root') do |docroot|
    server_options[:DocumentRoot] = File.expand_path(docroot)
  end
  opts.on('-a', '--adapter ADAPTER',
          'Use the ADAPTER (full Ruby class) for web server') do |adapter|
    self.adapter = if adapter.casecmp('webrick') == 0
                     YARD::Server::WebrickAdapter
                   elsif adapter.casecmp('rack') == 0
                     YARD::Server::RackAdapter
                   else
                     eval(adapter) # rubocop:disable Security/Eval
                   end
  end
  opts.on('-s', '--server TYPE',
          'Use a specific server type eg. thin,mongrel,cgi (Rack specific)') do |type|
    server_options[:server] = type
  end
  opts.on('--fork', 'Use process forking when serving requests') do
    options[:use_fork] = true
  end
  common_options(opts)
  opts.on('-e', '--load FILE',
          'A Ruby script to load before the source tree is parsed.') do |file|
    scripts << file
  end
  parse_options(opts, args)
  if args.empty? && libraries.empty?
    # No args - try to use current dir
    add_libraries([File.basename(Dir.pwd), nil])
    # Generate doc for first time
    # This is not necessary but makes for a better first-run experience
    libver = libraries.empty? ? nil : libraries.values.first.first
    generate_doc_for_first_time(libver) if libver && !libver.ready?
  else
    add_libraries(args)
    options[:single_library] = false if libraries.size > 1
  end
end