[ruby/optparse] [DOC] Add missing secition
Fixes https://github.com/ruby/optparse/pull/51 https://github.com/ruby/optparse/commit/667ab35f59
This commit is contained in:
parent
df941aa90d
commit
af4e839c47
9
doc/optparse/ruby/argument_abbreviation.rb
Normal file
9
doc/optparse/ruby/argument_abbreviation.rb
Normal file
@ -0,0 +1,9 @@
|
||||
require 'optparse'
|
||||
parser = OptionParser.new
|
||||
parser.on('-x', '--xxx=VALUE', %w[ABC def], 'Argument abbreviations') do |value|
|
||||
p ['--xxx', value]
|
||||
end
|
||||
parser.on('-y', '--yyy=VALUE', {"abc"=>"XYZ", def: "FOO"}, 'Argument abbreviations') do |value|
|
||||
p ['--yyy', value]
|
||||
end
|
||||
parser.parse!
|
@ -351,6 +351,29 @@ Executions:
|
||||
|
||||
Omitting an optional argument does not raise an error.
|
||||
|
||||
==== Argument Abbreviations
|
||||
|
||||
Specify an argument list as an Array or a Hash.
|
||||
|
||||
:include: ruby/argument_abbreviation.rb
|
||||
|
||||
When an argument is abbreviated, the expanded argument yielded.
|
||||
|
||||
Executions:
|
||||
|
||||
$ ruby argument_abbreviation.rb --help
|
||||
Usage: argument_abbreviation [options]
|
||||
Usage: argument_abbreviation [options]
|
||||
-x, --xxx=VALUE Argument abbreviations
|
||||
-y, --yyy=VALUE Argument abbreviations
|
||||
$ ruby argument_abbreviation.rb --xxx A
|
||||
["--xxx", "ABC"]
|
||||
$ ruby argument_abbreviation.rb --xxx c
|
||||
argument_abbreviation.rb:9:in `<main>': invalid argument: --xxx c (OptionParser::InvalidArgument)
|
||||
$ ruby argument_abbreviation.rb --yyy a --yyy d
|
||||
["--yyy", "XYZ"]
|
||||
["--yyy", "FOO"]
|
||||
|
||||
=== Argument Values
|
||||
|
||||
Permissible argument values may be restricted
|
||||
|
Loading…
x
Reference in New Issue
Block a user