diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-05 13:43:22 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-05 13:43:22 +0000 |
commit | 0fc35416644391b99759cceb7d992d802616b495 (patch) | |
tree | 38dded575d37f0e5780a828f32fa8b597db8c058 /lib/un.rb | |
parent | 4d076e91c8ade0015817fc18104b1271e2ac4a40 (diff) | |
download | bundler-0fc35416644391b99759cceb7d992d802616b495.tar.gz |
un.rb: help message
* lib/un.rb (setup): show help message by help method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/un.rb')
-rw-r--r-- | lib/un.rb | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -34,6 +34,7 @@ end # :nodoc: def setup(options = "", *long_options) + caller = caller_locations(1, 1)[0].label opt_hash = {} argv = [] OptionParser.new do |o| @@ -54,6 +55,10 @@ def setup(options = "", *long_options) end end o.on("-v") do opt_hash[:verbose] = true end + o.on("--help") do + UN.help([caller]) + exit + end o.order!(ARGV) do |x| if /[*?\[{]/ =~ x argv.concat(Dir[x]) @@ -338,12 +343,20 @@ end def help setup do |argv,| + UN.help(argv) + end +end + +module UN # :nodoc: + module_function + def help(argv, output: $stdout) all = argv.empty? 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] - print help.gsub(/^# ?/, "") + output << help.gsub(/^# ?/, "") + break if !all and argv.empty? end end end |