Skip to content

Improve ri --help and --version options handling #448

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 2 commits into from
Apr 19, 2017
Merged
Changes from all commits
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
62 changes: 39 additions & 23 deletions lib/rdoc/ri/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def self.process_args argv
opt.summary_indent = ' ' * 4

opt.banner = <<-EOT
Usage: #{opt.program_name} [options] [names...]
Usage: #{opt.program_name} [options] [name ...]

Where name can be:

Expand All @@ -132,8 +132,8 @@ def self.process_args argv

gem_name: | gem_name:README | gem_name:History

All class names may be abbreviated to their minimum unambiguous form. If a name
is ambiguous, all valid options will be listed.
All class names may be abbreviated to their minimum unambiguous form.
If a name is ambiguous, all valid options will be listed.

A '.' matches either class or instance methods, while #method
matches only instance and ::method matches only class methods.
Expand All @@ -151,23 +151,23 @@ def self.process_args argv
#{opt.program_name} zip
#{opt.program_name} rdoc:README

Note that shell quoting or escaping may be required for method names containing
punctuation:
Note that shell quoting or escaping may be required for method names
containing punctuation:

#{opt.program_name} 'Array.[]'
#{opt.program_name} compact\\!

To see the default directories ri will search, run:
To see the default directories #{opt.program_name} will search, run:

#{opt.program_name} --list-doc-dirs

Specifying the --system, --site, --home, --gems or --doc-dir options will
limit ri to searching only the specified directories.
Specifying the --system, --site, --home, --gems, or --doc-dir options
will limit ri to searching only the specified directories.

ri options may be set in the 'RI' environment variable.
ri options may be set in the RI environment variable.

The ri pager can be set with the 'RI_PAGER' environment variable or the
'PAGER' environment variable.
The ri pager can be set with the RI_PAGER environment variable
or the PAGER environment variable.
EOT

opt.separator nil
Expand Down Expand Up @@ -199,15 +199,15 @@ def self.process_args argv
opt.separator nil

opt.on("--[no-]pager",
"Send output directly to stdout,",
"rather than to a pager.") do |use_pager|
"Send output to a pager,",
"rather than directly to stdout.") do |use_pager|
options[:use_stdout] = !use_pager
end

opt.separator nil

opt.on("-T",
"Synonym for --no-pager") do
"Synonym for --no-pager.") do
options[:use_stdout] = true
end

Expand All @@ -220,7 +220,7 @@ def self.process_args argv

opt.separator nil

opt.on("--server [PORT]", Integer,
opt.on("--server[=PORT]", Integer,
"Run RDoc server on the given port.",
"The default port is 8214.") do |port|
options[:server] = port || 8214
Expand All @@ -235,13 +235,29 @@ def self.process_args argv
formatters -= %w[html label test] # remove useless output formats

opt.on("--format=NAME", "-f",
"Uses the selected formatter. The default",
"Use the selected formatter. The default",
"formatter is bs for paged output and ansi",
"otherwise. Valid formatters are:",
formatters.join(' '), formatters) do |value|
"otherwise. Valid formatters are:",
"#{formatters.join(', ')}.", formatters) do |value|
options[:formatter] = RDoc::Markup.const_get "To#{value.capitalize}"
end

opt.separator nil

opt.on("--help", "-h",
"Show help and exit.") do
puts opts
exit
end

opt.separator nil

opt.on("--version", "-v",
"Output version information and exit.") do
puts "#{opts.program_name} #{opts.version}"
exit
end

opt.separator nil
opt.separator "Data source options:"
opt.separator nil
Expand Down Expand Up @@ -273,7 +289,7 @@ def self.process_args argv
"Do not include documentation from",
"the Ruby standard library, site_lib,",
"installed gems, or ~/.rdoc.",
"Use with --doc-dir") do
"Use with --doc-dir.") do
options[:use_system] = false
options[:use_site] = false
options[:use_gems] = false
Expand All @@ -283,8 +299,8 @@ def self.process_args argv
opt.separator nil

opt.on("--[no-]system",
"Include documentation from Ruby's standard",
"library. Defaults to true.") do |value|
"Include documentation from Ruby's",
"standard library. Defaults to true.") do |value|
options[:use_system] = value
end

Expand Down Expand Up @@ -318,14 +334,14 @@ def self.process_args argv
opt.separator nil

opt.on("--[no-]profile",
"Run with the ruby profiler") do |value|
"Run with the ruby profiler.") do |value|
options[:profile] = value
end

opt.separator nil

opt.on("--dump=CACHE", File,
"Dumps data from an ri cache or data file") do |value|
"Dump data from an ri cache or data file.") do |value|
options[:dump_path] = value
end
end
Expand Down