Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'getoptlong'
- storage = ARGV.clone
- opts = GetoptLong.new(
- ['--help', '-h', GetoptLong::NO_ARGUMENT ],
- [ '--repeat', '-n', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--name', GetoptLong::OPTIONAL_ARGUMENT ]
- )
- puts "Before: #{ARGV.inspect}"
- opts.each { |opt, arg| puts "Parsed #{opt} = #{arg}" }
- puts "After: #{ARGV.inspect}"
- # Copy
- storage.each {|x| ARGV << x }
- opts = GetoptLong.new(
- ['--help', '-h', GetoptLong::NO_ARGUMENT ],
- [ '--repeat', '-n', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--name', GetoptLong::OPTIONAL_ARGUMENT ]
- )
- puts "Before 2: #{ARGV.inspect}"
- opts.each { |opt, arg| puts "Parsed #{opt} = #{arg}" }
- puts "After 2: #{ARGV.inspect}"
Add Comment
Please, Sign In to add comment