зеркало из https://github.com/github/ruby.git
* lib/optparse.rb (default_argv, Arguable#options): defaults strings
to be parsed to Arguable instance. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
66e67afd45
Коммит
898c734378
|
@ -1,3 +1,8 @@
|
|||
Wed Sep 21 07:43:58 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/optparse.rb (default_argv, Arguable#options): defaults strings
|
||||
to be parsed to Arguable instance.
|
||||
|
||||
Tue Sep 20 22:25:43 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/io/wait/lib/nonblock.rb: disable on platforms non-blocking flag
|
||||
|
|
|
@ -840,6 +840,7 @@ class OptionParser
|
|||
@banner = banner
|
||||
@summary_width = width
|
||||
@summary_indent = indent
|
||||
@default_argv = ARGV
|
||||
add_officious
|
||||
yield self if block_given?
|
||||
end
|
||||
|
@ -915,9 +916,13 @@ class OptionParser
|
|||
--- OptionParser#program_name=(name)
|
||||
Program name to be emitted in error message and default banner,
|
||||
defaulted to (({$0})).
|
||||
--- OptionParser#default_argv
|
||||
--- OptionParser#default_argv=(argv)
|
||||
Strings to be parsed in default.
|
||||
=end #'#"#`#
|
||||
attr_writer :banner, :program_name
|
||||
attr_accessor :summary_width, :summary_indent
|
||||
attr_accessor :default_argv
|
||||
|
||||
def banner
|
||||
unless @banner
|
||||
|
@ -1298,7 +1303,7 @@ class OptionParser
|
|||
order!(argv, &block)
|
||||
end
|
||||
|
||||
def order!(argv = ARGV, &nonopt)
|
||||
def order!(argv = default_argv, &nonopt)
|
||||
opt, arg, sw, val, rest = nil
|
||||
nonopt ||= proc {|arg| throw :terminate, arg}
|
||||
argv.unshift(arg) if arg = catch(:terminate) {
|
||||
|
@ -1385,7 +1390,7 @@ class OptionParser
|
|||
permute!(argv)
|
||||
end
|
||||
|
||||
def permute!(argv = ARGV)
|
||||
def permute!(argv = default_argv)
|
||||
nonopts = []
|
||||
arg = nil
|
||||
order!(argv) {|arg| nonopts << arg}
|
||||
|
@ -1411,7 +1416,7 @@ class OptionParser
|
|||
parse!(argv)
|
||||
end
|
||||
|
||||
def parse!(argv = ARGV)
|
||||
def parse!(argv = default_argv)
|
||||
if ENV.include?('POSIXLY_CORRECT')
|
||||
order!(argv)
|
||||
else
|
||||
|
@ -1803,6 +1808,7 @@ Extends command line arguments array to parse itself.
|
|||
=end #'#"#`#
|
||||
def options
|
||||
@optparse ||= OptionParser.new
|
||||
@optparse.default_argv = self
|
||||
block_given? or return @optparse
|
||||
begin
|
||||
yield @optparse
|
||||
|
|
Загрузка…
Ссылка в новой задаче