From b3b121496fa3ef61ad69b269e584b5b37bbddf6d Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 30 Aug 2008 01:42:03 +0000 Subject: [PATCH] * lib/rake.rb (Rake::Application#help): fix for OPTIONAL_ARGUMENT and multiple short options. [ruby-dev:36051] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/rake.rb | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2ca099f8f3..819a326bee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Aug 30 10:41:57 2008 Nobuyoshi Nakada + + * lib/rake.rb (Rake::Application#help): fix for OPTIONAL_ARGUMENT and + multiple short options. [ruby-dev:36051] + Sat Aug 30 08:59:25 2008 Nobuyoshi Nakada * include/ruby/intern.h (rb_file_s_absolute_path), diff --git a/lib/rake.rb b/lib/rake.rb index 068a0ceb21..0b21eb7350 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -1984,13 +1984,18 @@ module Rake puts puts "Options are ..." puts - OPTIONS.sort.each do |long, short, mode, desc| - if mode == GetoptLong::REQUIRED_ARGUMENT + OPTIONS.sort.each do |long, *short, mode, desc| + case mode + when GetoptLong::REQUIRED_ARGUMENT if desc =~ /\b([A-Z]{2,})\b/ long = long + "=#{$1}" end + when GetoptLong::OPTIONAL_ARGUMENT + if desc =~ /\b([A-Z]{2,})\b/ + long = long + "[=#{$1}]" + end end - printf " %-20s (%s)\n", long, short + printf " %-20s (%s)\n", long, short.join(", ") printf " %s\n", desc end end