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 (empty_argv || help_flag) && cmd != "cask"
|
||||
require "help"
|
||||
Homebrew::Help.help cmd, empty_argv: empty_argv
|
||||
# `Homebrew.help` never returns, except for unknown commands.
|
||||
Homebrew::Help.help cmd, remaining_args: args.remaining, empty_argv: empty_argv
|
||||
# `Homebrew::Help.help` never returns, except for unknown commands.
|
||||
end
|
||||
|
||||
if internal_cmd || Commands.external_ruby_v2_cmd_path(cmd)
|
||||
@ -140,7 +140,7 @@ begin
|
||||
end
|
||||
rescue UsageError => e
|
||||
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
|
||||
onoe "Kernel.exit" if args.debug? && !e.success?
|
||||
$stderr.puts e.backtrace if args.debug?
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
require "help"
|
||||
|
||||
module Homebrew
|
||||
def help(cmd = nil, flags = {})
|
||||
Help.help(cmd, flags)
|
||||
def help
|
||||
Help.help
|
||||
end
|
||||
end
|
||||
|
||||
@ -40,7 +40,7 @@ module Homebrew
|
||||
module Help
|
||||
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?
|
||||
# Handle `brew` (no arguments).
|
||||
if empty_argv
|
||||
@ -58,7 +58,7 @@ module Homebrew
|
||||
|
||||
# Display command-specific (or generic) help in response to `UsageError`.
|
||||
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
|
||||
onoe usage_error
|
||||
exit 1
|
||||
@ -68,16 +68,16 @@ module Homebrew
|
||||
return if path.nil?
|
||||
|
||||
# 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
|
||||
end
|
||||
|
||||
def command_help(cmd, path)
|
||||
def command_help(cmd, path, remaining_args:)
|
||||
# Only some types of commands can have a parser.
|
||||
output = if Commands.valid_internal_cmd?(cmd) ||
|
||||
Commands.valid_internal_dev_cmd?(cmd) ||
|
||||
Commands.external_ruby_v2_cmd_path(cmd)
|
||||
parser_help(path)
|
||||
parser_help(path, remaining_args: remaining_args)
|
||||
end
|
||||
|
||||
output ||= comment_help(path)
|
||||
@ -90,13 +90,13 @@ module Homebrew
|
||||
output
|
||||
end
|
||||
|
||||
def parser_help(path)
|
||||
def parser_help(path, remaining_args:)
|
||||
# Let OptionParser generate help text for commands which have a parser.
|
||||
cmd_parser = CLI::Parser.from_cmd_path(path)
|
||||
return unless cmd_parser
|
||||
|
||||
# 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
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user