diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-12-01 14:10:51 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-12-01 14:10:51 +0000 |
commit | 96986a7a9019ff063e2ef3ecbe223c0b23c68d52 (patch) | |
tree | a73fb4e9eb7da22d78886b0d12f3fe81c6831682 | |
parent | 8783c9ffcd22e5ab06896b8b13bd4beb6e797309 (diff) | |
download | ruby-96986a7a9019ff063e2ef3ecbe223c0b23c68d52.tar.gz |
* lib/optparse.rb (OptionParser::new): same as OptionParser#on but
returns new OptionParser::switch.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/optparse.rb | 30 |
2 files changed, 28 insertions, 7 deletions
@@ -1,3 +1,8 @@ +Sun Dec 1 23:04:03 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net> + + * lib/optparse.rb (OptionParser::new): same as OptionParser#on but + returns new OptionParser::switch. + Sun Dec 1 22:43:29 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net> * win32/win32.c (rb_w32_stat): empty path is invalid, and return diff --git a/lib/optparse.rb b/lib/optparse.rb index c92af70c98..cbbd572bda 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -899,7 +899,7 @@ Default options, which never appear in option summary. end private :notwice - def switch(*opts, &block) + def make_switch(*opts, &block) short, long, nolong, style, pattern, conv, not_pattern, not_conv, not_style = [], [], [] ldesc, sdesc, desc, arg = [], [], [] default_style = Switch::NoArgument @@ -1022,23 +1022,39 @@ Default options, which never appear in option summary. cf. ((<OptionParser#switch>)). =end #'#"#`# + def new(*opts, &block) + top.append(*(sw = make_switch(*opts, &block))) + sw[0] + end def on(*opts, &block) - top.append(*switch(*opts, &block)) + new(*opts, &block) self end - alias def_option on + alias def_option new + def new_head(*opts, &block) + top.prepend(*(sw = make_switch(*opts, &block))) + sw[0] + end def on_head(*opts, &block) - top.prepend(*switch(*opts, &block)) + new_head(*opts, &block) self end - alias def_head_option on_head + alias def_head_option new_head + def new_tail(*opts, &block) + base.append(*(sw = make_switch(*opts, &block))) + sw[0] + end def on_tail(*opts, &block) - base.append(*switch(*opts, &block)) + new_tail(*opts, &block) self end - alias def_tail_option on_tail + alias def_tail_option new_tail + + def separator(string) + top.append(string, nil, nil) + end =begin |