From d611e3e0f9e43cd3679c2d1c0cb4f721fae2d5ae Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Mon, 15 Jul 2024 11:28:39 -0400 Subject: [PATCH] Add `ShellCommand` module for shell command stubs --- Library/Homebrew/abstract_command.rb | 7 ------- Library/Homebrew/shell_command.rb | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 Library/Homebrew/shell_command.rb diff --git a/Library/Homebrew/abstract_command.rb b/Library/Homebrew/abstract_command.rb index 7bdc7b3907..23be6cb3dd 100644 --- a/Library/Homebrew/abstract_command.rb +++ b/Library/Homebrew/abstract_command.rb @@ -61,12 +61,5 @@ module Homebrew sig { abstract.void } def run; end - - sig { void } - def raise_sh_command_error! - raise StandardError, - "This command is just here for completions generation. " \ - "It's actually defined in `cmd/#{self.class.command_name}.sh` instead." - end end end diff --git a/Library/Homebrew/shell_command.rb b/Library/Homebrew/shell_command.rb new file mode 100644 index 0000000000..8527598c5c --- /dev/null +++ b/Library/Homebrew/shell_command.rb @@ -0,0 +1,18 @@ +# typed: strict +# frozen_string_literal: true + +module Homebrew + module ShellCommand + extend T::Helpers + + requires_ancestor { AbstractCommand } + + sig { void } + def run + sh_cmd_path = "#{self.class.dev_cmd? ? "dev-cmd" : "cmd"}/#{self.class.command_name}.sh" + raise StandardError, + "This command is just here for completions generation. " \ + "It's actually defined in `#{sh_cmd_path}` instead." + end + end +end