Skip to content

Commit

Permalink
Merge pull request Homebrew#18917 from Homebrew/send-args-to-cask-info
Browse files Browse the repository at this point in the history
cask/info: send missing args after removing openstruct
  • Loading branch information
MikeMcQuaid authored Dec 12, 2024
2 parents 0bcb764 + 9c0987c commit 9783ab0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
7 changes: 4 additions & 3 deletions Library/Homebrew/cask/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

require "json"
require "cmd/info"

module Cask
class Info
Expand Down Expand Up @@ -31,12 +32,12 @@ def self.get_info(cask)
output
end

sig { params(cask: Cask).void }
def self.info(cask)
sig { params(cask: Cask, args: Homebrew::Cmd::Info::Args).void }
def self.info(cask, args:)
puts get_info(cask)

require "utils/analytics"
::Utils::Analytics.cask_output(cask, args: Homebrew::CLI::Args.new)
::Utils::Analytics.cask_output(cask, args:)
end

sig { params(cask: Cask).returns(String) }
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def dep_display_s(dep)
def info_cask(cask)
require "cask/info"

Cask::Info.info(cask)
Cask::Info.info(cask, args:)
end
end
end
Expand Down
20 changes: 11 additions & 9 deletions Library/Homebrew/test/cask/info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
require "utils"

RSpec.describe Cask::Info, :cask do
let(:args) { instance_double(Homebrew::Cmd::Info::Args) }

before do
# Prevent unnecessary network requests in `Utils::Analytics.cask_output`
ENV["HOMEBREW_NO_ANALYTICS"] = "1"
end

it "displays some nice info about the specified Cask" do
expect do
described_class.info(Cask::CaskLoader.load("local-transmission"))
described_class.info(Cask::CaskLoader.load("local-transmission"), args:)
end.to output(<<~EOS).to_stdout
==> local-transmission: 2.61
https://transmissionbt.com/
Expand All @@ -27,7 +29,7 @@

it "prints cask dependencies if the Cask has any" do
expect do
described_class.info(Cask::CaskLoader.load("with-depends-on-cask-multiple"))
described_class.info(Cask::CaskLoader.load("with-depends-on-cask-multiple"), args:)
end.to output(<<~EOS).to_stdout
==> with-depends-on-cask-multiple: 1.2.3
https://brew.sh/with-depends-on-cask-multiple
Expand All @@ -46,7 +48,7 @@

it "prints cask and formulas dependencies if the Cask has both" do
expect do
described_class.info(Cask::CaskLoader.load("with-depends-on-everything"))
described_class.info(Cask::CaskLoader.load("with-depends-on-everything"), args:)
end.to output(<<~EOS).to_stdout
==> with-depends-on-everything: 1.2.3
https://brew.sh/with-depends-on-everything
Expand All @@ -65,7 +67,7 @@

it "prints auto_updates if the Cask has `auto_updates true`" do
expect do
described_class.info(Cask::CaskLoader.load("with-auto-updates"))
described_class.info(Cask::CaskLoader.load("with-auto-updates"), args:)
end.to output(<<~EOS).to_stdout
==> with-auto-updates: 1.0 (auto_updates)
https://brew.sh/autoupdates
Expand All @@ -82,7 +84,7 @@

it "prints caveats if the Cask provided one" do
expect do
described_class.info(Cask::CaskLoader.load("with-caveats"))
described_class.info(Cask::CaskLoader.load("with-caveats"), args:)
end.to output(<<~EOS).to_stdout
==> with-caveats: 1.2.3
https://brew.sh/
Expand All @@ -109,7 +111,7 @@

it 'does not print "Caveats" section divider if the caveats block has no output' do
expect do
described_class.info(Cask::CaskLoader.load("with-conditional-caveats"))
described_class.info(Cask::CaskLoader.load("with-conditional-caveats"), args:)
end.to output(<<~EOS).to_stdout
==> with-conditional-caveats: 1.2.3
https://brew.sh/
Expand All @@ -126,7 +128,7 @@

it "prints languages specified in the Cask" do
expect do
described_class.info(Cask::CaskLoader.load("with-languages"))
described_class.info(Cask::CaskLoader.load("with-languages"), args:)
end.to output(<<~EOS).to_stdout
==> with-languages: 1.2.3
https://brew.sh/
Expand All @@ -145,7 +147,7 @@

it 'does not print "Languages" section divider if the languages block has no output' do
expect do
described_class.info(Cask::CaskLoader.load("without-languages"))
described_class.info(Cask::CaskLoader.load("without-languages"), args:)
end.to output(<<~EOS).to_stdout
==> without-languages: 1.2.3
https://brew.sh/
Expand Down Expand Up @@ -173,7 +175,7 @@
expect(Cask::Tab).to receive(:for_cask).with(cask).and_return(tab)

expect do
described_class.info(cask)
described_class.info(cask, args:)
end.to output(<<~EOS).to_stdout
==> local-transmission: 2.61
https://transmissionbt.com/
Expand Down

0 comments on commit 9783ab0

Please sign in to comment.