* bin/erb: accepts options in more flexible styles.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
af91b42354
commit
bbd1a18aaf
@ -1,3 +1,7 @@
|
|||||||
|
Mon Dec 29 17:53:24 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||||
|
|
||||||
|
* bin/erb: accepts options in more flexible styles.
|
||||||
|
|
||||||
Mon Dec 29 17:25:17 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
Mon Dec 29 17:25:17 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||||
|
|
||||||
* lib/erb.rb (ERB): m17n of ERB. adds rdoc.
|
* lib/erb.rb (ERB): m17n of ERB. adds rdoc.
|
||||||
|
24
bin/erb
24
bin/erb
@ -12,9 +12,17 @@ class ERB
|
|||||||
arg = self.shift
|
arg = self.shift
|
||||||
return nil if arg == '--'
|
return nil if arg == '--'
|
||||||
if arg =~ /^-(.)(.*)/
|
if arg =~ /^-(.)(.*)/
|
||||||
return arg if $1 == '-'
|
if $1 == '-'
|
||||||
raise 'unknown switch "-"' if $2.index('-')
|
arg, @maybe_arg = arg.split(/=/, 2)
|
||||||
self.unshift "-#{$2}" if $2.size > 0
|
return arg
|
||||||
|
end
|
||||||
|
raise 'unknown switch "-"' if $2[0] == ?- and $1 != 'T'
|
||||||
|
if $2.size > 0
|
||||||
|
self.unshift "-#{$2}"
|
||||||
|
@maybe_arg = $2
|
||||||
|
else
|
||||||
|
@maybe_arg = nil
|
||||||
|
end
|
||||||
"-#{$1}"
|
"-#{$1}"
|
||||||
else
|
else
|
||||||
self.unshift arg
|
self.unshift arg
|
||||||
@ -23,7 +31,9 @@ class ERB
|
|||||||
end
|
end
|
||||||
|
|
||||||
def ARGV.req_arg
|
def ARGV.req_arg
|
||||||
self.shift || raise('missing argument')
|
(@maybe_arg || self.shift || raise('missing argument')).tap {
|
||||||
|
@maybe_arg = nil
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def trim_mode_opt(trim_mode, disable_percent)
|
def trim_mode_opt(trim_mode, disable_percent)
|
||||||
@ -94,11 +104,11 @@ class ERB
|
|||||||
-n print ruby script with line number
|
-n print ruby script with line number
|
||||||
-v enable verbose mode
|
-v enable verbose mode
|
||||||
-d set $DEBUG to true
|
-d set $DEBUG to true
|
||||||
-r [library] load a library
|
-r library load a library
|
||||||
-S [safe_level] set $SAFE (0..4)
|
-S safe_level set $SAFE (0..4)
|
||||||
-E ex[:in] set default external/internal encodings
|
-E ex[:in] set default external/internal encodings
|
||||||
-U set default encoding to UTF-8.
|
-U set default encoding to UTF-8.
|
||||||
-T [trim_mode] specify trim_mode (0..2, -)
|
-T trim_mode specify trim_mode (0..2, -)
|
||||||
-P ignore lines which start with "%"
|
-P ignore lines which start with "%"
|
||||||
EOU
|
EOU
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user