mirror of
https://github.com/donl/homebrew-cask-versions.git
synced 2026-07-17 06:16:47 -06:00
Including the case where a Cask is already installed. Always continue installing when multiple Casks are specified, only raising an exception at the end of the command (if some portion of the attempted install actions failed). Never exit with an error code if "already installed" was the only problem seen during the run. Also tweak error messages. Fixes #1347, #2677, #4785 Required disabling two tests regarding suggestions on Cask spelling errors.
82 lines
1.4 KiB
Ruby
82 lines
1.4 KiB
Ruby
class CaskError < RuntimeError; end
|
|
|
|
class CaskNotInstalledError < CaskError
|
|
attr_reader :cask
|
|
def initialize cask
|
|
@cask = cask
|
|
end
|
|
|
|
def to_s
|
|
"#{cask} is not installed"
|
|
end
|
|
end
|
|
|
|
class CaskUnavailableError < CaskError
|
|
attr_reader :name
|
|
def initialize name
|
|
@name = name
|
|
end
|
|
|
|
def to_s
|
|
"No available cask for #{name}"
|
|
end
|
|
end
|
|
|
|
class CaskAlreadyCreatedError < CaskError
|
|
attr_reader :name
|
|
def initialize name
|
|
@name = name
|
|
end
|
|
|
|
def to_s
|
|
"Cask for #{name} already exists. Use `brew cask edit #{name}` to see it."
|
|
end
|
|
end
|
|
|
|
class CaskAlreadyInstalledError < CaskError
|
|
attr_reader :name
|
|
def initialize name
|
|
@name = name
|
|
end
|
|
|
|
def to_s
|
|
"Cask for #{name} is already installed. Use `--force` to force re-install."
|
|
end
|
|
end
|
|
|
|
class CaskCommandFailedError < CaskError
|
|
def initialize cmd, output
|
|
@cmd = cmd
|
|
@output = output
|
|
end
|
|
|
|
def to_s;
|
|
<<-EOS.undent
|
|
Command failed to execute!
|
|
|
|
==> Failed command:
|
|
#{@cmd}
|
|
|
|
==> Output of failed command:
|
|
#{@output}
|
|
EOS
|
|
end
|
|
end
|
|
|
|
class CaskUnspecifiedError < CaskError
|
|
def to_s
|
|
"This command requires a cask's name"
|
|
end
|
|
end
|
|
|
|
class CaskInvalidError < CaskError
|
|
attr_reader :name, :submsg
|
|
def initialize(name, *submsg)
|
|
@name = name
|
|
@submsg = submsg.join(' ')
|
|
end
|
|
|
|
def to_s
|
|
"Cask '#{name}' definition is invalid" + (submsg.length > 0 ? ": #{submsg}" : '')
|
|
end
|
|
end
|