Add helpful error message when attempting to run brew cask

This commit is contained in:
Phoenix Eliot 2022-01-11 14:16:35 -05:00
parent 385892f3d2
commit f18cbd2066
2 changed files with 11 additions and 0 deletions

View File

@ -86,6 +86,10 @@ begin
require "commands"
require "settings"
# Print an error message and exit if the command is no longer supported
unsupported_cmd_message = Commands.unsupported_cmd?(cmd)
odie unsupported_cmd_message if unsupported_cmd_message
internal_cmd = Commands.valid_internal_cmd?(cmd) || Commands.valid_internal_dev_cmd?(cmd) if cmd
unless internal_cmd

View File

@ -30,6 +30,13 @@ module Commands
"lc" => "livecheck",
"tc" => "typecheck",
}.freeze
HOMEBREW_UNSUPPORTED_COMMAND_MESSAGES = {
"cask" => "`brew cask <command>` is no longer supported. Use `brew <command> --cask` instead.",
}.freeze
def unsupported_cmd?(cmd)
HOMEBREW_UNSUPPORTED_COMMAND_MESSAGES.fetch(cmd, nil)
end
def valid_internal_cmd?(cmd)
require?(HOMEBREW_CMD_PATH/cmd)