ruby-changes:29749
From: nobu <ko1@a...>
Date: Fri, 5 Jul 2013 22:43:42 +0900 (JST)
Subject: [ruby-changes:29749] nobu:r41801 (trunk): un.rb: help order
nobu 2013-07-05 22:43:25 +0900 (Fri, 05 Jul 2013) New Revision: 41801 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41801 Log: un.rb: help order * lib/un.rb (UN#help): show help messages in the given order. Modified files: trunk/lib/un.rb Index: lib/un.rb =================================================================== --- lib/un.rb (revision 41800) +++ lib/un.rb (revision 41801) @@ -351,15 +351,25 @@ module UN # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/un.rb#L351 module_function def help(argv, output: $stdout) all = argv.empty? + cmd = nil + if all + store = proc {|msg| output << msg} + else + messages = {} + store = proc {|msg| messages[cmd] = msg} + end open(__FILE__) do |me| while me.gets("##\n") if help = me.gets("\n\n") - if all or argv.delete help[/^#\s*ruby\s.*-e\s+(\w+)/, 1] - output << help.gsub(/^# ?/, "") - break if !all and argv.empty? + if all or argv.include?(cmd = help[/^#\s*ruby\s.*-e\s+(\w+)/, 1]) + store[help.gsub(/^# ?/, "")] + break unless all or argv.size > messages.size end end end end + if messages + argv.each {|cmd| output << messages[cmd]} + end end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/