summaryrefslogtreecommitdiff
path: root/lib/rubygems/command.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-22 02:52:35 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-22 02:52:35 +0000
commitb551e8c8b36766651be4e782e09e3b02e7d14a10 (patch)
treee164a1ef908bd4451568abf05b688f1593915b81 /lib/rubygems/command.rb
parent65544f575b25b18dc27f9364f973556ddb48538f (diff)
* lib/rubygems: update to 1.3.6.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/command.rb')
-rw-r--r--lib/rubygems/command.rb95
1 files changed, 49 insertions, 46 deletions
diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb
index dab4366..08692bd 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 <COMMAND> 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 <COMMAND> 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: