From b551e8c8b36766651be4e782e09e3b02e7d14a10 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 22 Feb 2010 02:52:35 +0000 Subject: * lib/rubygems: update to 1.3.6. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/command.rb | 95 +++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 46 deletions(-) (limited to 'lib/rubygems/command.rb') diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb index dab4366270..08692bdb70 100644 --- a/lib/rubygems/command.rb +++ b/lib/rubygems/command.rb @@ -160,8 +160,8 @@ class Gem::Command end ## - # Get the single gem name from the command line. Fail if there is no gem - # name or if there is more than one gem name given. + # Get a single gem name from the command line. Fail if there is no gem name + # or if there is more than one gem name given. def get_one_gem_name args = options[:args] @@ -248,11 +248,12 @@ class Gem::Command # Invoke the command with the given list of arguments. def invoke(*args) - handle_options(args) - if options[:help] + handle_options args + + if options[:help] then show_help - elsif @when_invoked - @when_invoked.call(options) + elsif @when_invoked then + @when_invoked.call options else execute end @@ -362,37 +363,39 @@ class Gem::Command def create_option_parser @parser = OptionParser.new - @parser.separator("") + @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 - @parser.separator("") unless arguments.empty? - @parser.separator(" Arguments:") + @parser.separator nil + @parser.separator " Arguments:" arguments.split(/\n/).each do |arg_desc| - @parser.separator(" #{arg_desc}") + @parser.separator " #{arg_desc}" end - @parser.separator("") end - @parser.separator(" Summary:") + @parser.separator nil + @parser.separator " Summary:" wrap(@summary, 80 - 4).split("\n").each do |line| - @parser.separator(" #{line.strip}") + @parser.separator " #{line.strip}" end if description then formatted = description.split("\n\n").map do |chunk| - wrap(chunk, 80 - 4) - end.join("\n") + wrap chunk, 80 - 4 + end.join "\n" - @parser.separator "" + @parser.separator nil @parser.separator " Description:" formatted.split("\n").each do |line| @parser.separator " #{line.rstrip}" @@ -400,10 +403,10 @@ class Gem::Command end unless defaults_str.empty? - @parser.separator("") - @parser.separator(" Defaults:") + @parser.separator nil + @parser.separator " Defaults:" defaults_str.split(/\n/).each do |line| - @parser.separator(" #{line}") + @parser.separator " #{line}" end end end @@ -471,33 +474,33 @@ class Gem::Command # :stopdoc: - HELP = %{ - RubyGems is a sophisticated package manager for Ruby. This is a - basic help message containing pointers to more information. - - Usage: - gem -h/--help - gem -v/--version - gem command [arguments...] [options...] - - Examples: - gem install rake - gem list --local - gem build package.gemspec - gem help install - - Further help: - gem help commands list all 'gem' commands - gem help examples show some examples of usage - gem help platforms show information about platforms - gem help show help on COMMAND - (e.g. 'gem help install') - gem server present a web page at - http://localhost:8808/ - with info about installed gems - Further information: - http://rubygems.rubyforge.org - }.gsub(/^ /, '') + HELP = <<-HELP +RubyGems is a sophisticated package manager for Ruby. This is a +basic help message containing pointers to more information. + + Usage: + gem -h/--help + gem -v/--version + gem command [arguments...] [options...] + + Examples: + gem install rake + gem list --local + gem build package.gemspec + gem help install + + Further help: + gem help commands list all 'gem' commands + gem help examples show some examples of usage + gem help platforms show information about platforms + gem help show help on COMMAND + (e.g. 'gem help install') + gem server present a web page at + http://localhost:8808/ + with info about installed gems + Further information: + http://rubygems.rubyforge.org + HELP # :startdoc: -- cgit v1.2.3