8000 Rdoc by BurdetteLamar · Pull Request #15 · ruby/optparse · GitHub
[go: up one dir, main page]

Skip to content

Rdoc #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 10, 2021
Merged

Rdoc #15

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Show --help for all examples
  • Loading branch information
BurdetteLamar committed Apr 9, 2021
commit 06105dce982249855f5538e3811d0bbb13a75c36
2 changes: 1 addition & 1 deletion doc/option_params.rdoc
8000
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ Executions:

$ ruby long_with_negation.rb --help
Usage: long_with_negation [options]
--[no-]binary
--[no-]binary Long name with negation
$ ruby long_with_negation.rb --binary
[true, TrueClass]
$ ruby long_with_negation.rb --no-binary
Expand Down
4 changes: 2 additions & 2 deletions doc/ruby/long_names.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'optparse'
parser = OptionParser.new
parser.on('--xxx') do |value|
parser.on('--xxx', 'Long name') do |value|
p ['-xxx', value]
end
parser.on('--y1%', '--z2#') do |value|
parser.on('--y1%', '--z2#', "Two long names") do |value|
p ['--y1% or --z2#', value]
end
parser.parse!
2 changes: 1 addition & 1 deletion doc/ruby/long_with_negation.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'optparse'
parser = OptionParser.new
parser.on('--[no-]binary') do |value|
parser.on('--[no-]binary', 'Long name with negation') do |value|
p [value, value.class]
end
parser.parse!
4 changes: 2 additions & 2 deletions doc/ruby/optional_argument.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'optparse'
parser = OptionParser.new
parser.on('-x [XXX]', '--xxx') do |value|
parser.on('-x [XXX]', '--xxx', 'Optional argument via short name') do |value|
p ['--xxx', value]
end
parser.on('-y', '--yyy [YYY]') do |value|
parser.on('-y', '--yyy [YYY]', 'Optional argument via long name') do |value|
p ['--yyy', value]
end
parser.parse!
4 changes: 2 additions & 2 deletions doc/ruby/required_argument.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'optparse'
parser = OptionParser.new
parser.on('-x XXX', '--xxx') do |value|
parser.on('-x XXX', '--xxx', 'Required argument via short name') do |value|
p ['--xxx', value]
end
parser.on('-y', '--y YYY') do |value|
parser.on('-y', '--y YYY', 'Required argument via long name') do |value|
p ['--yyy', value]
end
parser.parse!
4 changes: 2 additions & 2 deletions doc/ruby/short_names.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'optparse'
parser = OptionParser.new
parser.on('-x') do |value|
parser.on('-x', 'Short name') do |value|
p ['x', value]
end
parser.on('-1', '-%') do |value|
parser.on('-1', '-%', 'Two short names') do |value|
p ['-1 or -%', value]
end
parser.parse!
23 changes: 22 additions & 1 deletion doc/tutorial.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ and an option with two short names (aliases, in effect) <tt>-y</tt> and <tt>-z</

Executions:

$ ruby short_names.rb --help
Usage: short_names [options]
-x Short name
-1, -% Two short names
$ ruby short_names.rb -x
["x", true]
$ ruby short_names.rb -1
Expand Down Expand Up @@ -103,6 +107,10 @@ and an option with two long names (aliases, in effect) <tt>--y1%</tt> and <tt>--

Executions:

$ ruby long_names.rb --help
Usage: long_names [options]
--xxx Long name
--y1%, --z2# Two long names
$ ruby long_names.rb --xxx
["-xxx", true]
$ ruby long_names.rb --y1%
Expand All @@ -120,7 +128,7 @@ Executions:

$ ruby long_with_negation.rb --help
Usage: long_with_negation [options]
--[no-]binary
--[no-]binary Long name with negation
$ ruby long_with_negation.rb --binary
[true, TrueClass]
$ ruby long_with_negation.rb --no-binary
Expand All @@ -138,6 +146,11 @@ defines options that each have both a short and a long name.

Executions:

$ ruby mixed_names.rb --help
Usage: mixed_names [options]
-x, --xxx Short and long, no argument
-y, --yyyYYY Short and long, required argument
-z, --zzz [ZZZ] Short and long, optional argument
$ ruby mixed_names.rb -x
["--xxx", true]
$ ruby mixed_names.rb --xxx
Expand Down Expand Up @@ -181,6 +194,10 @@ When an option is found, the given argument is yielded.

Executions:

$ ruby required_argument.rb --help
Usage: required_argument [options]
-x, --xxx XXX Required argument via short name
-y, --y YYY Required argument via long name
$ ruby required_argument.rb -x AAA
["--xxx", "AAA"]
$ ruby required_argument.rb -y BBB
Expand All @@ -206,6 +223,10 @@ When an option with an argument is found, the given argument yielded.

Executions:

$ ruby optional_argument.rb --help
Usage: optional_argument [options]
-x, --xxx [XXX] Optional argument via short name
-y, --yyy [YYY] Optional argument via long name
$ ruby optional_argument.rb -x AAA
["--xxx", "AAA"]
$ ruby optional_argument.rb -y BBB
Expand Down
0