Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
OptionParser#environment
environment(env = File.basename($0, '.*'))
lib/optparse.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/optparse.rb, line 1957
def environment(env = File.basename($0, '.*'))
env = ENV[env] || ENV[env.upcase] or return
require 'shellwords'
parse(*Shellwords.shellwords(env))
end
Parses environment variable env or its uppercase with splitting like a shell.
env defaults to the basename of the program.