From a0a7f355d5e1a4bcbfd5c45c12f1566944da4a32 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Sat, 10 Aug 2024 09:22:12 -0700 Subject: [PATCH] Create dummy brew cmd --- Library/Homebrew/abstract_command.rb | 5 +++++ Library/Homebrew/brew.rb | 2 +- Library/Homebrew/cli/parser.rb | 13 +++++-------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/abstract_command.rb b/Library/Homebrew/abstract_command.rb index 23be6cb3dd..6e9e1b7187 100644 --- a/Library/Homebrew/abstract_command.rb +++ b/Library/Homebrew/abstract_command.rb @@ -62,4 +62,9 @@ module Homebrew sig { abstract.void } def run; end end + + module Cmd + # The command class for `brew` itself, allowing its args to be parsed. + class Brew < AbstractCommand; end + end end diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 114f034dd3..4e6b9726f7 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -48,7 +48,7 @@ begin ARGV.delete_at(help_cmd_index) if help_cmd_index require "cli/parser" - args = Homebrew::CLI::Parser.new.parse(ARGV.dup.freeze, ignore_invalid_options: true) + args = Homebrew::CLI::Parser.new(Homebrew::Cmd::Brew).parse(ARGV.dup.freeze, ignore_invalid_options: true) Context.current = args.context path = PATH.new(ENV.fetch("PATH")) diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index ea9a159fb9..7a2ccf61a8 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -167,14 +167,11 @@ module Homebrew @command_name = T.let(T.must(cmd_location.label).chomp("_args").tr("_", "-"), String) @is_dev_cmd = T.let(T.must(cmd_location.absolute_path).start_with?(Commands::HOMEBREW_DEV_CMD_PATH), T::Boolean) - # We allow this path only from `brew.rb`: - if @command_name != "
" - odeprecated( - "`brew #{@command_name}', which does not inherit from from Homebrew::AbstractCommand. This command " \ - "needs to be refactored, as it is written in a style that", - disable_for_developers: false, - ) - end + odeprecated( + "`brew #{@command_name}', which does not inherit from from Homebrew::AbstractCommand. This command " \ + "needs to be refactored, as it is written in a style that", + disable_for_developers: false, + ) end @constraints = T.let([], T::Array[[String, String]])