Deprecate remaining cask commands.

This commit is contained in:
Markus Reiter 2020-11-18 08:10:21 +01:00
parent b192cef352
commit 3c2ec1c60f
18 changed files with 81 additions and 153 deletions

View File

@ -54,13 +54,23 @@ module Cask
}.freeze }.freeze
DEPRECATED_COMMANDS = { 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::Doctor => "brew doctor --verbose",
Cmd::Edit => "brew edit [--cask]",
Cmd::Fetch => "brew fetch [--cask]",
Cmd::Home => "brew home", Cmd::Home => "brew home",
Cmd::List => "brew list --cask", Cmd::Info => "brew info [--cask]",
Cmd::Outdated => "brew outdated --cask", Cmd::Install => "brew install [--cask]",
Cmd::Reinstall => "brew reinstall", Cmd::List => "brew list [--cask]",
Cmd::Upgrade => "brew upgrade --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 }.freeze
sig { returns(String) } sig { returns(String) }

View File

@ -35,7 +35,9 @@ module Cask
exec_editor cask_path exec_editor cask_path
rescue CaskUnavailableError => e rescue CaskUnavailableError => e
reason = e.reason.empty? ? +"" : +"#{e.reason} " 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) raise e.class.new(e.token, reason.freeze)
end end

View File

@ -64,7 +64,7 @@ module Cask
puts <<~EOS puts <<~EOS
#{cask} #{versions.to_sentence} #{"is".pluralize(versions.count)} still installed. #{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 EOS
end end
end end

View File

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

View File

@ -111,7 +111,7 @@ module Cask
sig { returns(String) } sig { returns(String) }
def to_s def to_s
%Q(Cask '#{token}' already exists. Run #{Formatter.identifier("brew cask edit #{token}")} to edit it.) %Q(Cask '#{token}' already exists. Run #{Formatter.identifier("brew edit --cask #{token}")} to edit it.)
end end
end end
@ -142,7 +142,7 @@ module Cask
def to_s def to_s
<<~EOS <<~EOS
Cask '#{token}' requires XQuartz/X11, which can be installed using Homebrew Cask by running: 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: or manually, by downloading the package from:
#{Formatter.url("https://www.xquartz.org/")} #{Formatter.url("https://www.xquartz.org/")}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,6 +11,10 @@ describe Cask::Cmd, :cask do
context "::run" do context "::run" do
let(:noop_command) { double("Cmd::Noop", run: nil) } 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 it "prints help output when subcommand receives `--help` flag" do
expect { expect {
described_class.run("info", "--help") described_class.run("info", "--help")

View File

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

View File

@ -138,21 +138,21 @@ describe JavaRequirement do
describe "#suggestion" do describe "#suggestion" do
context "without specific version" do context "without specific version" do
its(:suggestion) { is_expected.to match(/brew cask install adoptopenjdk/) } its(:suggestion) { is_expected.to match(/brew install --cask adoptopenjdk/) }
its(:cask) { is_expected.to eq("adoptopenjdk") } its(:cask) { is_expected.to eq("adoptopenjdk") }
end end
context "with version 1.8" do context "with version 1.8" do
subject { described_class.new(%w[1.8]) } subject { described_class.new(%w[1.8]) }
its(:suggestion) { is_expected.to match(%r{brew cask install homebrew/cask-versions/adoptopenjdk8}) } its(:suggestion) { is_expected.to match(%r{brew install --cask homebrew/cask-versions/adoptopenjdk8}) }
its(:cask) { is_expected.to eq("homebrew/cask-versions/adoptopenjdk8") } its(:cask) { is_expected.to eq("homebrew/cask-versions/adoptopenjdk8") }
end end
context "with version 1.8+" do context "with version 1.8+" do
subject { described_class.new(%w[1.8+]) } subject { described_class.new(%w[1.8+]) }
its(:suggestion) { is_expected.to match(/brew cask install adoptopenjdk/) } its(:suggestion) { is_expected.to match(/brew install --cask adoptopenjdk/) }
its(:cask) { is_expected.to eq("adoptopenjdk") } its(:cask) { is_expected.to eq("adoptopenjdk") }
end end
end end

View File

@ -71,39 +71,9 @@ Homebrew Cask provides a friendly CLI workflow for the administration of macOS a
Commands: 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` - `help`
<br>Print help for `cask` commands. <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` See also: `man brew`
### `cleanup` [*`options`*] [*`formula`*|*`cask`*] ### `cleanup` [*`options`*] [*`formula`*|*`cask`*]
@ -243,10 +213,10 @@ error message if no logs are found.
* `-p`, `--private`: * `-p`, `--private`:
The Gist will be marked private and will not appear in listings but will be accessible with its link. 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 Open a *`formula`* or *`cask`*'s homepage in a browser, or open
if no formula is provided. Homebrew's own homepage if no argument is provided.
### `info` [*`options`*] [*`formula`*|*`cask`*] ### `info` [*`options`*] [*`formula`*|*`cask`*]
@ -849,11 +819,11 @@ supplied by the user.
* `--commit`: * `--commit`:
When passed with `--write`, generate a new commit after writing changes to the cask file. When passed with `--write`, generate a new commit after writing changes to the cask file.
* `--no-audit`: * `--no-audit`:
Don't run `brew cask audit` before opening the PR. Don't run `brew audit` before opening the PR.
* `--online`: * `--online`:
Run `brew cask audit --online` before opening the PR. Run `brew audit --online` before opening the PR.
* `--no-style`: * `--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`: * `--no-browse`:
Print the pull request URL instead of opening in a browser. Print the pull request URL instead of opening in a browser.
* `--no-fork`: * `--no-fork`:

View File

@ -67,71 +67,11 @@ Homebrew Cask provides a friendly CLI workflow for the administration of macOS a
Commands: Commands:
. .
.TP .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 \fBhelp\fR
. .
.br .br
Print help for \fBcask\fR commands\. 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 .P
See also: \fBman brew\fR See also: \fBman brew\fR
. .
@ -322,8 +262,8 @@ Automatically create a new issue in the appropriate GitHub repository after crea
\fB\-p\fR, \fB\-\-private\fR \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\. The Gist will be marked private and will not appear in listings but will be accessible with its link\.
. .
.SS "\fBhome\fR [\fIformula\fR]" .SS "\fBhome\fR [\fIformula\fR|\fIcask\fR]"
Open \fIformula\fR\'s homepage in a browser, or open Homebrew\'s own homepage if no formula is provided\. 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]" .SS "\fBinfo\fR [\fIoptions\fR] [\fIformula\fR|\fIcask\fR]"
Display brief statistics for your Homebrew installation\. Display brief statistics for your Homebrew installation\.
@ -1173,15 +1113,15 @@ When passed with \fB\-\-write\fR, generate a new commit after writing changes to
. .
.TP .TP
\fB\-\-no\-audit\fR \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 .TP
\fB\-\-online\fR \fB\-\-online\fR
Run \fBbrew cask audit \-\-online\fR before opening the PR\. Run \fBbrew audit \-\-online\fR before opening the PR\.
. .
.TP .TP
\fB\-\-no\-style\fR \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 .TP
\fB\-\-no\-browse\fR \fB\-\-no\-browse\fR