зеркало из https://github.com/github/ruby.git
* lib/optparse.rb (OptionParser::Officious): moved from DefaultList.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
7c5c394f09
Коммит
4c718c753e
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,7 @@
|
|||
Tue Nov 9 14:27:18 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/optparse.rb (OptionParser::Officious): moved from DefaultList.
|
||||
|
||||
Tue Nov 9 00:50:06 2004 Dave Thomas <dave@pragprog.com>
|
||||
|
||||
* lib/rdoc/rdoc.rb: Change version numbering of RDoc and ri
|
||||
|
@ -46,11 +50,11 @@ Sat Nov 6 11:18:59 2004 Tadayoshi Funaba <tadf@dotrb.org>
|
|||
|
||||
Fri Nov 5 19:07:16 2004 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* ext/nkf: follow CVS Head of original nkf.
|
||||
* ext/nkf: follow CVS Head of original nkf.
|
||||
|
||||
Fri Nov 5 18:12:42 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tk/lib/tk/scrollable.rb: divide Scrollable module into
|
||||
* ext/tk/lib/tk/scrollable.rb: divide Scrollable module into
|
||||
X_Scrollable and Y_Scrollable
|
||||
|
||||
* ext/tk/lib/tk/entry.rb: include X_Scrollable instead of Scrollable
|
||||
|
@ -100,8 +104,8 @@ Thu Nov 4 21:25:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
|||
|
||||
Thu Nov 4 21:13:48 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c(typelib_file_from_typelib): search "win16"
|
||||
entry to get library path.
|
||||
* ext/win32ole/win32ole.c(typelib_file_from_typelib): search "win16"
|
||||
entry to get library path.
|
||||
|
||||
* ext/win32ole/win32ole.c(oletypelib_path): ditto.
|
||||
|
||||
|
@ -140,12 +144,12 @@ Wed Nov 3 17:19:59 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
|||
|
||||
Wed Nov 3 17:02:48 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tk/lib/tk.rb: support to use different Tcl commands between
|
||||
* ext/tk/lib/tk.rb: support to use different Tcl commands between
|
||||
configure and configinfo
|
||||
|
||||
* ext/tk/lib/font.rb: ditto.
|
||||
|
||||
* ext/tk/lib/itemconfig.rb: support to use different Tcl commands
|
||||
* ext/tk/lib/itemconfig.rb: support to use different Tcl commands
|
||||
between item_configure and item_configinfo
|
||||
|
||||
* ext/tk/lib/itemfont.rb: ditto.
|
||||
|
@ -159,7 +163,7 @@ Wed Nov 3 15:38:28 2004 Kouhei Sutou <kou@cozmixng.org>
|
|||
* test/rss/*.rb: removed tab width configuration headers.
|
||||
|
||||
* test/rss/test_maker_{0.9,1.0}.rb: sort -> do_sort.
|
||||
|
||||
|
||||
* lib/rss/maker/*.rb: changed API to RSS version independence.
|
||||
|
||||
* lib/rss/maker/base.rb
|
||||
|
@ -276,7 +280,7 @@ Sun Oct 31 14:18:56 2004 Minero Aoki <aamine@loveruby.net>
|
|||
|
||||
Sat Oct 30 15:24:41 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c: add WIN32OLE_TYPELIB class. add
|
||||
* ext/win32ole/win32ole.c: add WIN32OLE_TYPELIB class. add
|
||||
WIN32OLE#ole_typelib method.
|
||||
|
||||
* ext/win32ole/tests/testOLETYPELIB.rb: add WIN32OLE_TYPELIB class.
|
||||
|
|
|
@ -718,30 +718,38 @@ class OptionParser
|
|||
DefaultList.long[''] = Switch::NoArgument.new {throw :terminate}
|
||||
|
||||
#
|
||||
# Default options, which never appear in option summary.
|
||||
# OptionParser::Officious
|
||||
# Default options for ARGV, which never appear in option summary.
|
||||
#
|
||||
Officious = {}
|
||||
|
||||
# --help
|
||||
# Shows option summary.
|
||||
Officious['help'] = proc do |parser|
|
||||
Switch::NoArgument.new do
|
||||
puts parser.help
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
# --version
|
||||
# Shows version string if (({::Version})) is defined.
|
||||
#
|
||||
DefaultList.long['help'] = Switch::NoArgument.new do
|
||||
puts ARGV.options
|
||||
exit
|
||||
end
|
||||
DefaultList.long['version'] = Switch::OptionalArgument.new do |pkg|
|
||||
if pkg
|
||||
begin
|
||||
require 'optparse/version'
|
||||
rescue LoadError
|
||||
pkg = nil
|
||||
else
|
||||
show_version(*pkg.split(/,/))
|
||||
Officious['version'] = proc do |parser|
|
||||
Switch::OptionalArgument.new do |pkg|
|
||||
if pkg
|
||||
begin
|
||||
require 'optparse/version'
|
||||
rescue LoadError
|
||||
else
|
||||
show_version(*pkg.split(/,/)) or
|
||||
abort("#{parser.program_name}: no version found in package #{pkg}")
|
||||
exit
|
||||
end
|
||||
end
|
||||
v = parser.ver or abort("#{parser.program_name}: version unknown")
|
||||
puts v
|
||||
exit
|
||||
end
|
||||
unless pkg
|
||||
v = ARGV.options.ver and puts v
|
||||
end
|
||||
exit
|
||||
end
|
||||
|
||||
# :startdoc:
|
||||
|
@ -809,9 +817,18 @@ class OptionParser
|
|||
@banner = banner
|
||||
@summary_width = width
|
||||
@summary_indent = indent
|
||||
add_officious
|
||||
yield self if block_given?
|
||||
end
|
||||
|
||||
# :nodoc:
|
||||
def add_officious
|
||||
list = base()
|
||||
Officious.each_pair do |opt, block|
|
||||
list.long[opt] ||= block.call(self)
|
||||
end
|
||||
end
|
||||
|
||||
=begin
|
||||
--- OptionParser.terminate([arg])
|
||||
Terminates option parsing. Optional parameter ((|arg|)) would be
|
||||
|
@ -907,7 +924,7 @@ class OptionParser
|
|||
attr_writer :version, :release
|
||||
|
||||
def version
|
||||
@version || (defined?(::Version) && ::Version) || (defined?(::VERSION) && ::VERSION)
|
||||
@version || (defined?(::Version) && ::Version)
|
||||
end
|
||||
|
||||
def release
|
||||
|
@ -1562,6 +1579,21 @@ class OptionParser
|
|||
s
|
||||
end
|
||||
|
||||
=begin
|
||||
: Regexp
|
||||
Regular expression with option.
|
||||
=end
|
||||
accept(Regexp, %r"\A/((?:\\.|[^\\])*)/([[:alpha:]]+)?\z|.*") do |all, s, o|
|
||||
f = 0
|
||||
if o
|
||||
f |= Regexp::IGNORECASE if /i/ =~ o
|
||||
f |= Regexp::MULTILINE if /m/ =~ o
|
||||
f |= Regexp::EXTENDED if /x/ =~ o
|
||||
k = o.delete("^imx")
|
||||
end
|
||||
Regexp.new(s || all, f, k)
|
||||
end
|
||||
|
||||
|
||||
=begin
|
||||
= Exceptions
|
||||
|
@ -1644,7 +1676,7 @@ argument.
|
|||
((<OptionParser::ParseError>))
|
||||
=end #'#"#`#
|
||||
class NeedlessArgument < ParseError
|
||||
const_set(:Reason, 'needles argument'.freeze)
|
||||
const_set(:Reason, 'needless argument'.freeze)
|
||||
end
|
||||
|
||||
=begin
|
||||
|
|
|
@ -3,45 +3,47 @@
|
|||
class << OptionParser
|
||||
def show_version(*pkg)
|
||||
progname = ARGV.options.program_name
|
||||
show = proc do |klass, version|
|
||||
version = version.join(".") if Array === version
|
||||
result = false
|
||||
show = proc do |klass, cname, version|
|
||||
str = "#{progname}"
|
||||
str << ": #{klass}" unless klass == Object
|
||||
str << " version #{version}"
|
||||
case
|
||||
when klass.const_defined?(:Release)
|
||||
str << " (#{klass.const_get(:Release)})"
|
||||
when klass.const_defined?(:RELEASE)
|
||||
str << " (#{klass.const_get(:Release)})"
|
||||
unless klass == ::Object and cname == :VERSION
|
||||
version = version.join(".") if Array === version
|
||||
str << ": #{klass}" unless klass == Object
|
||||
str << " version #{version}"
|
||||
end
|
||||
[:Release, :RELEASE].find do |rel|
|
||||
if klass.const_defined?(rel)
|
||||
str << " (#{klass.const_get(rel)})"
|
||||
end
|
||||
end
|
||||
puts str
|
||||
result = true
|
||||
end
|
||||
if pkg.size == 1 and pkg[0] == "all"
|
||||
self.search_const(::Object, /\AV(?:ERSION|ersion)\z/) do |klass, cname, version|
|
||||
unless cname[1] == ?e and klass.const_defined?(:Version)
|
||||
show.call(klass, version)
|
||||
show.call(klass, cname.intern, version)
|
||||
end
|
||||
end
|
||||
else
|
||||
pkg.each do |pkg|
|
||||
/\A[A-Z]\w*((::|\/)[A-Z]\w*)*\z/ni =~ pkg or next
|
||||
begin
|
||||
pkg = eval(pkg)
|
||||
pkg = pkg.split(/::|\//).inject(::Object) {|m, c| m.const_get(c)}
|
||||
v = case
|
||||
when pkg.const_defined?(:Version)
|
||||
pkg.const_get(:Version)
|
||||
pkg.const_get(n = :Version)
|
||||
when pkg.const_defined?(:VERSION)
|
||||
pkg.const_get(:VERSION)
|
||||
pkg.const_get(n = :VERSION)
|
||||
else
|
||||
n = nil
|
||||
"unknown"
|
||||
end
|
||||
show.call(pkg, v)
|
||||
show.call(pkg, n, v)
|
||||
rescue NameError
|
||||
puts "#{progname}: #$!"
|
||||
end
|
||||
end
|
||||
end
|
||||
exit
|
||||
result
|
||||
end
|
||||
|
||||
def each_const(path, klass = ::Object)
|
||||
|
|
Загрузка…
Ссылка в новой задаче