Pass remaining args to Help.
This commit is contained in:
parent
490e503b1b
commit
6524802079
@ -104,8 +104,8 @@ begin
|
|||||||
# - if cmd is Cask, let Cask handle the help command instead
|
# - if cmd is Cask, let Cask handle the help command instead
|
||||||
if (empty_argv || help_flag) && cmd != "cask"
|
if (empty_argv || help_flag) && cmd != "cask"
|
||||||
require "help"
|
require "help"
|
||||||
Homebrew::Help.help cmd, empty_argv: empty_argv
|
Homebrew::Help.help cmd, remaining_args: args.remaining, empty_argv: empty_argv
|
||||||
# `Homebrew.help` never returns, except for unknown commands.
|
# `Homebrew::Help.help` never returns, except for unknown commands.
|
||||||
end
|
end
|
||||||
|
|
||||||
if internal_cmd || Commands.external_ruby_v2_cmd_path(cmd)
|
if internal_cmd || Commands.external_ruby_v2_cmd_path(cmd)
|
||||||
@ -140,7 +140,7 @@ begin
|
|||||||
end
|
end
|
||||||
rescue UsageError => e
|
rescue UsageError => e
|
||||||
require "help"
|
require "help"
|
||||||
Homebrew::Help.help cmd, usage_error: e.message
|
Homebrew::Help.help cmd, remaining_args: args.remaining, usage_error: e.message
|
||||||
rescue SystemExit => e
|
rescue SystemExit => e
|
||||||
onoe "Kernel.exit" if args.debug? && !e.success?
|
onoe "Kernel.exit" if args.debug? && !e.success?
|
||||||
$stderr.puts e.backtrace if args.debug?
|
$stderr.puts e.backtrace if args.debug?
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
require "help"
|
require "help"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
def help(cmd = nil, flags = {})
|
def help
|
||||||
Help.help(cmd, flags)
|
Help.help
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -40,7 +40,7 @@ module Homebrew
|
|||||||
module Help
|
module Help
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def help(cmd = nil, empty_argv: false, usage_error: nil)
|
def help(cmd = nil, empty_argv: false, usage_error: nil, remaining_args: [])
|
||||||
if cmd.nil?
|
if cmd.nil?
|
||||||
# Handle `brew` (no arguments).
|
# Handle `brew` (no arguments).
|
||||||
if empty_argv
|
if empty_argv
|
||||||
@ -58,7 +58,7 @@ module Homebrew
|
|||||||
|
|
||||||
# Display command-specific (or generic) help in response to `UsageError`.
|
# Display command-specific (or generic) help in response to `UsageError`.
|
||||||
if usage_error
|
if usage_error
|
||||||
$stderr.puts path ? command_help(cmd, path) : HOMEBREW_HELP
|
$stderr.puts path ? command_help(cmd, path, remaining_args: remaining_args) : HOMEBREW_HELP
|
||||||
$stderr.puts
|
$stderr.puts
|
||||||
onoe usage_error
|
onoe usage_error
|
||||||
exit 1
|
exit 1
|
||||||
@ -68,16 +68,16 @@ module Homebrew
|
|||||||
return if path.nil?
|
return if path.nil?
|
||||||
|
|
||||||
# Display help for internal command (or generic help if undocumented).
|
# Display help for internal command (or generic help if undocumented).
|
||||||
puts command_help(cmd, path)
|
puts command_help(cmd, path, remaining_args: remaining_args)
|
||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def command_help(cmd, path)
|
def command_help(cmd, path, remaining_args:)
|
||||||
# Only some types of commands can have a parser.
|
# Only some types of commands can have a parser.
|
||||||
output = if Commands.valid_internal_cmd?(cmd) ||
|
output = if Commands.valid_internal_cmd?(cmd) ||
|
||||||
Commands.valid_internal_dev_cmd?(cmd) ||
|
Commands.valid_internal_dev_cmd?(cmd) ||
|
||||||
Commands.external_ruby_v2_cmd_path(cmd)
|
Commands.external_ruby_v2_cmd_path(cmd)
|
||||||
parser_help(path)
|
parser_help(path, remaining_args: remaining_args)
|
||||||
end
|
end
|
||||||
|
|
||||||
output ||= comment_help(path)
|
output ||= comment_help(path)
|
||||||
@ -90,13 +90,13 @@ module Homebrew
|
|||||||
output
|
output
|
||||||
end
|
end
|
||||||
|
|
||||||
def parser_help(path)
|
def parser_help(path, remaining_args:)
|
||||||
# Let OptionParser generate help text for commands which have a parser.
|
# Let OptionParser generate help text for commands which have a parser.
|
||||||
cmd_parser = CLI::Parser.from_cmd_path(path)
|
cmd_parser = CLI::Parser.from_cmd_path(path)
|
||||||
return unless cmd_parser
|
return unless cmd_parser
|
||||||
|
|
||||||
# Try parsing arguments here in order to show formula options in help output.
|
# Try parsing arguments here in order to show formula options in help output.
|
||||||
cmd_parser.parse(Homebrew.args.remaining, ignore_invalid_options: true)
|
cmd_parser.parse(remaining_args, ignore_invalid_options: true)
|
||||||
cmd_parser.generate_help_text
|
cmd_parser.generate_help_text
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user