Create dummy brew cmd

This commit is contained in:
Douglas Eichelberger 2024-08-10 09:22:12 -07:00
parent 4fd659797f
commit a0a7f355d5
3 changed files with 11 additions and 9 deletions

View File

@ -62,4 +62,9 @@ module Homebrew
sig { abstract.void } sig { abstract.void }
def run; end def run; end
end end
module Cmd
# The command class for `brew` itself, allowing its args to be parsed.
class Brew < AbstractCommand; end
end
end end

View File

@ -48,7 +48,7 @@ begin
ARGV.delete_at(help_cmd_index) if help_cmd_index ARGV.delete_at(help_cmd_index) if help_cmd_index
require "cli/parser" 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 Context.current = args.context
path = PATH.new(ENV.fetch("PATH")) path = PATH.new(ENV.fetch("PATH"))

View File

@ -167,15 +167,12 @@ module Homebrew
@command_name = T.let(T.must(cmd_location.label).chomp("_args").tr("_", "-"), String) @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), @is_dev_cmd = T.let(T.must(cmd_location.absolute_path).start_with?(Commands::HOMEBREW_DEV_CMD_PATH),
T::Boolean) T::Boolean)
# We allow this path only from `brew.rb`:
if @command_name != "<main>"
odeprecated( odeprecated(
"`brew #{@command_name}', which does not inherit from from Homebrew::AbstractCommand. This command " \ "`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", "needs to be refactored, as it is written in a style that",
disable_for_developers: false, disable_for_developers: false,
) )
end end
end
@constraints = T.let([], T::Array[[String, String]]) @constraints = T.let([], T::Array[[String, String]])
@conflicts = T.let([], T::Array[T::Array[String]]) @conflicts = T.let([], T::Array[T::Array[String]])