From 73f0fc3f1abdc3f9d570570311c628d17b57575b Mon Sep 17 00:00:00 2001 From: apainintheneck Date: Sat, 4 Mar 2023 12:25:08 -0800 Subject: [PATCH] brew/irb: add cask monkey patch This makes it easier to load casks in repl sessions and matches what we already do with formulae. --- Library/Homebrew/dev-cmd/irb.rb | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/dev-cmd/irb.rb b/Library/Homebrew/dev-cmd/irb.rb index 3f032038be..7d7c5a81ae 100644 --- a/Library/Homebrew/dev-cmd/irb.rb +++ b/Library/Homebrew/dev-cmd/irb.rb @@ -2,18 +2,27 @@ # frozen_string_literal: true require "formulary" +require "cask/cask_loader" require "cli/parser" -class Symbol - def f(*args) - Formulary.factory(to_s, *args) - end -end - class String def f(*args) Formulary.factory(self, *args) end + + def c(config: nil) + Cask::CaskLoader.load(self, config: config) + end +end + +class Symbol + def f(*args) + to_s.f(*args) + end + + def c(config: nil) + to_s.c(config: config) + end end module Homebrew @@ -45,6 +54,9 @@ module Homebrew :hub.f.latest_version_installed? :lua.f.methods - 1.methods :mpd.f.recursive_dependencies.reject(&:installed?) + + 'vlc'.c # => instance of the vlc cask + :tsh.c.livecheckable? EOS return end