method

create_option_parser

Importance_0
v1_9_3_392 - Show latest stable - 0 notes - Class: Command
create_option_parser() private

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/rubygems/command.rb, line 383
  def create_option_parser
    @parser = OptionParser.new

    @parser.separator nil
    regular_options = @option_groups.delete :options

    configure_options "", regular_options

    @option_groups.sort_by { |n,_| n.to_s }.each do |group_name, option_list|
      @parser.separator nil
      configure_options group_name, option_list
    end

    @parser.separator nil
    configure_options "Common", Gem::Command.common_options

    unless arguments.empty?
      @parser.separator nil
      @parser.separator "  Arguments:"
      arguments.split(/\n/).each do |arg_desc|
        @parser.separator "    #{arg_desc}"
      end
    end

    if @summary then
      @parser.separator nil
      @parser.separator "  Summary:"
      wrap(@summary, 80 - 4).split("\n").each do |line|
        @parser.separator "    #{line.strip}"
      end
    end

    if description then
      formatted = description.split("\n\n").map do |chunk|
        wrap chunk, 80 - 4
      end.join "\n"

      @parser.separator nil
      @parser.separator "  Description:"
      formatted.split("\n").each do |line|
        @parser.separator "    #{line.rstrip}"
      end
    end

    unless defaults_str.empty?
      @parser.separator nil
      @parser.separator "  Defaults:"
      defaults_str.split(/\n/).each do |line|
        @parser.separator "    #{line}"
      end
    end
  end
Register or log in to add new notes.