I am using Ruby's OptionParser (require 'optparse'
) processing a "verbose" option that can be either true or false. It is in the code like this:
parser.on('-v', '--[no-]verbose', 'Verbose mode') do |v|
self.verbose = v
end
I support specifying options in an environment variable (I prepend its content to ARGV), so it is possible to set verbose mode on in that environment variable, and override it on the command line with --no-verbose
. However, I cannot find a way to override it with a short option. I've tried these without success:
-v-
-v0
-v=0
I found the source code at https://github.com/ruby/ruby/blob/trunk/lib/optparse.rb but could not figure out the answer from that.
How can I do this?