Merge pull request #9247 from reitermarkus/deprecate-cask-commands

Deprecate remaining cask commands.
This commit is contained in:
Mike McQuaid 2020-11-25 10:10:56 +00:00 committed by GitHub
commit 918fbcc263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 87 additions and 199 deletions

View File

@ -54,35 +54,26 @@ module Cask
}.freeze
DEPRECATED_COMMANDS = {
Cmd::Cache => "brew --cache --cask",
Cmd::Cache => "brew --cache [--cask]",
Cmd::Audit => "brew audit [--cask]",
Cmd::Cat => "brew cat [--cask]",
Cmd::Create => "brew create --cask --set-name <name> <url>",
Cmd::Doctor => "brew doctor --verbose",
Cmd::Edit => "brew edit [--cask]",
Cmd::Fetch => "brew fetch [--cask]",
Cmd::Help => "brew help",
Cmd::Home => "brew home",
Cmd::List => "brew list --cask",
Cmd::Outdated => "brew outdated --cask",
Cmd::Reinstall => "brew reinstall",
Cmd::Upgrade => "brew upgrade --cask",
Cmd::Info => "brew info [--cask]",
Cmd::Install => "brew install [--cask]",
Cmd::List => "brew list [--cask]",
Cmd::Outdated => "brew outdated [--cask]",
Cmd::Reinstall => "brew reinstall [--cask]",
Cmd::Style => "brew style",
Cmd::Uninstall => "brew uninstall [--cask]",
Cmd::Upgrade => "brew upgrade [--cask]",
Cmd::Zap => "brew upgrade --zap [--cask]",
}.freeze
sig { returns(String) }
def self.description
max_command_length = Cmd.commands.map(&:length).max
command_lines = Cmd.command_classes
.select(&:visible?)
.reject { |command| DEPRECATED_COMMANDS.key?(command) }
.map do |klass|
" - #{"`#{klass.command_name}`".ljust(max_command_length + 2)} #{klass.short_description}\n"
end
<<~EOS
Homebrew Cask provides a friendly CLI workflow for the administration of macOS applications distributed as binaries.
Commands:
#{command_lines.join}
See also: `man brew`
EOS
end
def self.parser(&block)
Homebrew::CLI::Parser.new do
if block
@ -91,7 +82,9 @@ module Cask
usage_banner <<~EOS
`cask` <command> [<options>] [<cask>]
#{Cmd.description}
Homebrew Cask provides a friendly CLI workflow for the administration of macOS applications distributed as binaries.
See also: `man brew`
EOS
end

View File

@ -35,7 +35,9 @@ module Cask
exec_editor cask_path
rescue CaskUnavailableError => e
reason = e.reason.empty? ? +"" : +"#{e.reason} "
reason.concat("Run #{Formatter.identifier("brew cask create #{e.token}")} to create a new Cask.")
reason.concat(
"Run #{Formatter.identifier("brew create --cask --set-name #{e.token} <url>")} to create a new Cask.",
)
raise e.class.new(e.token, reason.freeze)
end

View File

@ -64,7 +64,7 @@ module Cask
puts <<~EOS
#{cask} #{versions.to_sentence} #{"is".pluralize(versions.count)} still installed.
Remove #{(versions.count == 1) ? "it" : "them all"} with `brew cask uninstall --force #{cask}`.
Remove #{(versions.count == 1) ? "it" : "them all"} with `brew uninstall --cask --force #{cask}`.
EOS
end
end

View File

@ -112,17 +112,17 @@ module Cask
if java_version == :any
<<~EOS
#{@cask} requires Java. You can install the latest version with:
brew cask install adoptopenjdk
brew install --cask adoptopenjdk
EOS
elsif java_version.include?("11") || java_version.include?("+")
<<~EOS
#{@cask} requires Java #{java_version}. You can install the latest version with:
brew cask install adoptopenjdk
brew install --cask adoptopenjdk
EOS
else
<<~EOS
#{@cask} requires Java #{java_version}. You can install it with:
brew cask install homebrew/cask-versions/adoptopenjdk#{java_version}
brew install --cask homebrew/cask-versions/adoptopenjdk#{java_version}
EOS
end
end

View File

@ -142,7 +142,7 @@ module Cask
def to_s
<<~EOS
Cask '#{token}' requires XQuartz/X11, which can be installed using Homebrew Cask by running:
#{Formatter.identifier("brew cask install xquartz")}
#{Formatter.identifier("brew install --cask xquartz")}
or manually, by downloading the package from:
#{Formatter.url("https://www.xquartz.org/")}

View File

@ -474,7 +474,7 @@ module Cask
end
def zap
ohai %Q(Implied "brew cask uninstall #{@cask}")
ohai %Q(Implied "brew uninstall --cask #{@cask}")
uninstall_artifacts
if (zap_stanzas = @cask.artifacts.select { |a| a.is_a?(Artifact::Zap) }).empty?
opoo "No zap stanza present for Cask '#{@cask}'"

View File

@ -1,7 +1,8 @@
# typed: false
# typed: true
# frozen_string_literal: true
require "cli/parser"
require "formula"
module Homebrew
extend T::Sig
@ -12,14 +13,15 @@ module Homebrew
def home_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`home` [<formula>]
`home` [<formula>|<cask>]
Open <formula>'s homepage in a browser, or open Homebrew's own homepage
if no formula is provided.
Open a <formula> or <cask>'s homepage in a browser, or open
Homebrew's own homepage if no argument is provided.
EOS
end
end
sig { void }
def home
args = home_args.parse

View File

@ -322,7 +322,7 @@ class Reporter
new_tap.install unless new_tap.installed?
ohai "#{name} has been moved to Homebrew.", <<~EOS
To uninstall the cask run:
brew cask uninstall --force #{name}
brew uninstall --cask --force #{name}
EOS
next if (HOMEBREW_CELLAR/new_name.split("/").last).directory?
@ -352,8 +352,8 @@ class Reporter
system HOMEBREW_BREW_FILE, "unlink", name
ohai "brew cleanup"
system HOMEBREW_BREW_FILE, "cleanup"
ohai "brew cask install #{new_name}"
system HOMEBREW_BREW_FILE, "cask", "install", new_name
ohai "brew install --cask #{new_name}"
system HOMEBREW_BREW_FILE, "install", "--cask", new_name
ohai <<~EOS
#{name} has been moved to Homebrew Cask.
The existing keg has been unlinked.
@ -365,7 +365,7 @@ class Reporter
To uninstall the formula and install the cask run:
brew uninstall --force #{name}
brew tap #{new_tap_name}
brew cask install #{new_name}
brew install --cask #{new_name}
EOS
end
else

View File

@ -100,8 +100,11 @@ module Commands
cmds.sort
end
def internal_commands_paths
find_commands HOMEBREW_CMD_PATH
def internal_commands_paths(cask: true)
cmds = find_commands HOMEBREW_CMD_PATH
# can be removed when cask commands are removed and no longer odeprecated/odisabled
cmds.delete(HOMEBREW_CMD_PATH/"cask.rb") unless cask
cmds
end
def internal_developer_commands_paths

View File

@ -30,11 +30,11 @@ module Homebrew
description: "When passed with `--write`, generate a new commit after writing changes "\
"to the cask file."
switch "--no-audit",
description: "Don't run `brew cask audit` before opening the PR."
description: "Don't run `brew audit` before opening the PR."
switch "--online",
description: "Run `brew cask audit --online` before opening the PR."
description: "Run `brew audit --online` before opening the PR."
switch "--no-style",
description: "Don't run `brew cask style --fix` before opening the PR."
description: "Don't run `brew style --fix` before opening the PR."
switch "--no-browse",
description: "Print the pull request URL instead of opening in a browser."
switch "--no-fork",
@ -232,49 +232,49 @@ module Homebrew
def run_cask_audit(cask, old_contents, args:)
if args.dry_run?
if args.no_audit?
ohai "Skipping `brew cask audit`"
ohai "Skipping `brew audit`"
elsif args.online?
ohai "brew cask audit --online #{cask.sourcefile_path.basename}"
ohai "brew audit --cask --online #{cask.sourcefile_path.basename}"
else
ohai "brew cask audit #{cask.sourcefile_path.basename}"
ohai "brew audit --cask #{cask.sourcefile_path.basename}"
end
return
end
failed_audit = false
if args.no_audit?
ohai "Skipping `brew cask audit`"
ohai "Skipping `brew audit`"
elsif args.online?
system HOMEBREW_BREW_FILE, "cask", "audit", "--online", cask.sourcefile_path
system HOMEBREW_BREW_FILE, "audit", "--cask", "--online", cask.sourcefile_path
failed_audit = !$CHILD_STATUS.success?
else
system HOMEBREW_BREW_FILE, "cask", "audit", cask.sourcefile_path
system HOMEBREW_BREW_FILE, "audit", "--cask", cask.sourcefile_path
failed_audit = !$CHILD_STATUS.success?
end
return unless failed_audit
cask.sourcefile_path.atomic_write(old_contents)
odie "`brew cask audit` failed!"
odie "`brew audit` failed!"
end
def run_cask_style(cask, old_contents, args:)
if args.dry_run?
if args.no_style?
ohai "Skipping `brew cask style --fix`"
ohai "Skipping `brew style --fix`"
else
ohai "brew cask style --fix #{cask.sourcefile_path.basename}"
ohai "brew style --fix #{cask.sourcefile_path.basename}"
end
return
end
failed_style = false
if args.no_style?
ohai "Skipping `brew cask style --fix`"
ohai "Skipping `brew style --fix`"
else
system HOMEBREW_BREW_FILE, "cask", "style", "--fix", cask.sourcefile_path
system HOMEBREW_BREW_FILE, "style", "--fix", cask.sourcefile_path
failed_style = !$CHILD_STATUS.success?
end
return unless failed_style
cask.sourcefile_path.atomic_write(old_contents)
odie "`brew cask style --fix` failed!"
odie "`brew style --fix` failed!"
end
end

View File

@ -67,7 +67,7 @@ module Homebrew
template = (SOURCE_PATH/"brew.1.md.erb").read
variables = OpenStruct.new
variables[:commands] = generate_cmd_manpages(Commands.internal_commands_paths)
variables[:commands] = generate_cmd_manpages(Commands.internal_commands_paths(cask: false))
variables[:developer_commands] = generate_cmd_manpages(Commands.internal_developer_commands_paths)
variables[:official_external_commands] =
generate_cmd_manpages(Commands.official_external_commands_paths(quiet: quiet))

View File

@ -23,13 +23,13 @@ module Homebrew
There are three versions of MacTeX.
Full installation:
brew cask install mactex
brew install --cask mactex
Full installation without bundled applications:
brew cask install mactex-no-gui
brew install --cask mactex-no-gui
Minimal installation:
brew cask install basictex
brew install --cask basictex
EOS
else
generic_disallowed_reason(name)
@ -47,7 +47,7 @@ module Homebrew
def suggest_command(name, command)
suggestion = <<~EOS
Found a cask named "#{name}" instead. Try
brew cask #{command} #{name}
brew #{command} --cask #{name}
EOS
case command

View File

@ -30,7 +30,7 @@ module Homebrew
EOS
when "macruby" then <<~EOS
MacRuby has been discontinued. Consider RubyMotion:
brew cask install rubymotion
brew install --cask rubymotion
EOS
when /(lib)?lzma/ then <<~EOS
lzma is now part of the xz formula:
@ -74,8 +74,8 @@ module Homebrew
when "ngrok" then <<~EOS
Upstream sunsetted 1.x in March 2016 and 2.x is not open-source.
If you wish to use the 2.x release you can install with Homebrew Cask:
brew cask install ngrok
If you wish to use the 2.x release you can install it with:
brew install --cask ngrok
EOS
when "cargo" then <<~EOS
cargo is part of the rust formula:

View File

@ -43,8 +43,8 @@ class Requirement
s = "#{class_name} unsatisfied!\n"
if cask
s += <<~EOS
You can install with Homebrew Cask:
brew cask install #{cask}
You can install the necessary cask with:
brew install --cask #{cask}
EOS
end

View File

@ -78,7 +78,7 @@ class JavaRequirement < Requirement
title_string = " #{title}" if title
<<~EOS
Install#{title_string} with Homebrew Cask:
brew cask install #{token}
brew install --cask #{token}
EOS
end
end

View File

@ -11,6 +11,10 @@ describe Cask::Cmd, :cask do
context "::run" do
let(:noop_command) { double("Cmd::Noop", run: nil) }
before do
allow(Homebrew).to receive(:raise_deprecation_exceptions?).and_return(false)
end
it "prints help output when subcommand receives `--help` flag" do
expect {
described_class.run("info", "--help")

View File

@ -97,7 +97,7 @@ describe Homebrew::MissingFormula do
let(:show_info) { false }
it { is_expected.to match(/Found a cask named "local-caffeine" instead./) }
it { is_expected.to match(/Try\n brew cask install local-caffeine/) }
it { is_expected.to match(/Try\n brew install --cask local-caffeine/) }
end
context "with a formula name that is a cask and show_info: true" do
@ -123,7 +123,7 @@ describe Homebrew::MissingFormula do
let(:command) { "install" }
it { is_expected.to match(/Found a cask named "local-caffeine" instead./) }
it { is_expected.to match(/Try\n brew cask install local-caffeine/) }
it { is_expected.to match(/Try\n brew install --cask local-caffeine/) }
end
context "brew uninstall" do
@ -138,7 +138,7 @@ describe Homebrew::MissingFormula do
end
it { is_expected.to match(/Found a cask named "local-caffeine" instead./) }
it { is_expected.to match(/Try\n brew cask uninstall local-caffeine/) }
it { is_expected.to match(/Try\n brew uninstall --cask local-caffeine/) }
end
end

View File

@ -65,47 +65,6 @@ Uninstall formulae that were only installed as a dependency of another formula a
* `-n`, `--dry-run`:
List what would be uninstalled, but do not actually uninstall anything.
### `cask` *`command`* [*`options`*] [*`cask`*]
Homebrew Cask provides a friendly CLI workflow for the administration of macOS applications distributed as binaries.
Commands:
- `audit`
<br>Check *`cask`* for Homebrew coding style violations.
- `cat`
<br>Dump raw source of a *`cask`* to the standard output.
- `create`
<br>Creates the given *`cask`* and opens it in an editor.
- `edit`
<br>Open the given *`cask`* for editing.
- `fetch`
<br>Downloads remote application files to local cache.
- `help`
<br>Print help for `cask` commands.
- `info`
<br>Displays information about the given *`cask`*.
- `install`
<br>Installs the given *`cask`*.
- `style`
<br>Checks style of the given *`cask`* using RuboCop.
- `uninstall`
<br>Uninstalls the given *`cask`*.
- `zap`
<br>Zaps all files associated with the given *`cask`*.
See also: `man brew`
### `cleanup` [*`options`*] [*`formula`*|*`cask`*]
Remove stale lock files and outdated downloads for all formulae and casks,
@ -243,10 +202,10 @@ error message if no logs are found.
* `-p`, `--private`:
The Gist will be marked private and will not appear in listings but will be accessible with its link.
### `home` [*`formula`*]
### `home` [*`formula`*|*`cask`*]
Open *`formula`*'s homepage in a browser, or open Homebrew's own homepage
if no formula is provided.
Open a *`formula`* or *`cask`*'s homepage in a browser, or open
Homebrew's own homepage if no argument is provided.
### `info` [*`options`*] [*`formula`*|*`cask`*]
@ -849,11 +808,11 @@ supplied by the user.
* `--commit`:
When passed with `--write`, generate a new commit after writing changes to the cask file.
* `--no-audit`:
Don't run `brew cask audit` before opening the PR.
Don't run `brew audit` before opening the PR.
* `--online`:
Run `brew cask audit --online` before opening the PR.
Run `brew audit --online` before opening the PR.
* `--no-style`:
Don't run `brew cask style --fix` before opening the PR.
Don't run `brew style --fix` before opening the PR.
* `--no-browse`:
Print the pull request URL instead of opening in a browser.
* `--no-fork`:

View File

@ -60,81 +60,6 @@ Uninstall formulae that were only installed as a dependency of another formula a
\fB\-n\fR, \fB\-\-dry\-run\fR
List what would be uninstalled, but do not actually uninstall anything\.
.
.SS "\fBcask\fR \fIcommand\fR [\fIoptions\fR] [\fIcask\fR]"
Homebrew Cask provides a friendly CLI workflow for the administration of macOS applications distributed as binaries\.
.
.P
Commands:
.
.TP
\fBaudit\fR
.
.br
Check \fIcask\fR for Homebrew coding style violations\.
.
.TP
\fBcat\fR
.
.br
Dump raw source of a \fIcask\fR to the standard output\.
.
.TP
\fBcreate\fR
.
.br
Creates the given \fIcask\fR and opens it in an editor\.
.
.TP
\fBedit\fR
.
.br
Open the given \fIcask\fR for editing\.
.
.TP
\fBfetch\fR
.
.br
Downloads remote application files to local cache\.
.
.TP
\fBhelp\fR
.
.br
Print help for \fBcask\fR commands\.
.
.TP
\fBinfo\fR
.
.br
Displays information about the given \fIcask\fR\.
.
.TP
\fBinstall\fR
.
.br
Installs the given \fIcask\fR\.
.
.TP
\fBstyle\fR
.
.br
Checks style of the given \fIcask\fR using RuboCop\.
.
.TP
\fBuninstall\fR
.
.br
Uninstalls the given \fIcask\fR\.
.
.TP
\fBzap\fR
.
.br
Zaps all files associated with the given \fIcask\fR\.
.
.P
See also: \fBman brew\fR
.
.SS "\fBcleanup\fR [\fIoptions\fR] [\fIformula\fR|\fIcask\fR]"
Remove stale lock files and outdated downloads for all formulae and casks, and remove old versions of installed formulae\. If arguments are specified, only do this for the given formulae and casks\. Removes all downloads more than 120 days old\. This can be adjusted with \fBHOMEBREW_CLEANUP_MAX_AGE_DAYS\fR\.
.
@ -322,8 +247,8 @@ Automatically create a new issue in the appropriate GitHub repository after crea
\fB\-p\fR, \fB\-\-private\fR
The Gist will be marked private and will not appear in listings but will be accessible with its link\.
.
.SS "\fBhome\fR [\fIformula\fR]"
Open \fIformula\fR\'s homepage in a browser, or open Homebrew\'s own homepage if no formula is provided\.
.SS "\fBhome\fR [\fIformula\fR|\fIcask\fR]"
Open a \fIformula\fR or \fIcask\fR\'s homepage in a browser, or open Homebrew\'s own homepage if no argument is provided\.
.
.SS "\fBinfo\fR [\fIoptions\fR] [\fIformula\fR|\fIcask\fR]"
Display brief statistics for your Homebrew installation\.
@ -1173,15 +1098,15 @@ When passed with \fB\-\-write\fR, generate a new commit after writing changes to
.
.TP
\fB\-\-no\-audit\fR
Don\'t run \fBbrew cask audit\fR before opening the PR\.
Don\'t run \fBbrew audit\fR before opening the PR\.
.
.TP
\fB\-\-online\fR
Run \fBbrew cask audit \-\-online\fR before opening the PR\.
Run \fBbrew audit \-\-online\fR before opening the PR\.
.
.TP
\fB\-\-no\-style\fR
Don\'t run \fBbrew cask style \-\-fix\fR before opening the PR\.
Don\'t run \fBbrew style \-\-fix\fR before opening the PR\.
.
.TP
\fB\-\-no\-browse\fR