From 652480207979026e9db9ab5e19e69cbe636d6964 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 2 Aug 2020 15:36:05 +0200 Subject: [PATCH] Pass remaining args to `Help`. --- Library/Homebrew/brew.rb | 6 +++--- Library/Homebrew/cmd/help.rb | 4 ++-- Library/Homebrew/help.rb | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 719b39f18e..d33b6948ab 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -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? diff --git a/Library/Homebrew/cmd/help.rb b/Library/Homebrew/cmd/help.rb index d75c424e1c..acd6849ca5 100644 --- a/Library/Homebrew/cmd/help.rb +++ b/Library/Homebrew/cmd/help.rb @@ -3,7 +3,7 @@ require "help" module Homebrew - def help(cmd = nil, flags = {}) - Help.help(cmd, flags) + def help + Help.help end end diff --git a/Library/Homebrew/help.rb b/Library/Homebrew/help.rb index 53c3e46d56..12283523d8 100644 --- a/Library/Homebrew/help.rb +++ b/Library/Homebrew/help.rb @@ -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