| 
									
										
										
										
											2024-06-30 19:07:38 +01:00
										 |  |  | # typed: strict | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-21 10:39:08 -07:00
										 |  |  | require "abstract_command" | 
					
						
							| 
									
										
										
										
											2024-07-03 20:34:44 +01:00
										 |  |  | require "formula" | 
					
						
							| 
									
										
										
										
											2020-12-01 12:05:21 +01:00
										 |  |  | require "formulary" | 
					
						
							| 
									
										
										
										
											2023-03-04 12:25:08 -08:00
										 |  |  | require "cask/cask_loader" | 
					
						
							| 
									
										
										
										
											2018-03-24 20:04:45 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 12:25:08 -08:00
										 |  |  | class String | 
					
						
							| 
									
										
										
										
											2024-04-21 14:34:55 -07:00
										 |  |  |   # @!visibility private | 
					
						
							| 
									
										
										
										
											2024-06-30 19:07:38 +01:00
										 |  |  |   sig { params(args: Integer).returns(Formula) } | 
					
						
							| 
									
										
										
										
											2015-01-04 21:37:27 -05:00
										 |  |  |   def f(*args) | 
					
						
							| 
									
										
										
										
											2023-03-04 12:25:08 -08:00
										 |  |  |     Formulary.factory(self, *args) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-21 14:34:55 -07:00
										 |  |  |   # @!visibility private | 
					
						
							| 
									
										
										
										
											2024-06-30 19:07:38 +01:00
										 |  |  |   sig { params(config: T.nilable(T::Hash[Symbol, T.untyped])).returns(Cask::Cask) } | 
					
						
							| 
									
										
										
										
											2023-03-04 12:25:08 -08:00
										 |  |  |   def c(config: nil) | 
					
						
							| 
									
										
										
										
											2024-03-07 16:20:20 +00:00
										 |  |  |     Cask::CaskLoader.load(self, config:) | 
					
						
							| 
									
										
										
										
											2012-08-31 08:09:50 -04:00
										 |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							| 
									
										
										
										
											2017-02-23 06:04:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 12:25:08 -08:00
										 |  |  | class Symbol | 
					
						
							| 
									
										
										
										
											2024-04-21 14:34:55 -07:00
										 |  |  |   # @!visibility private | 
					
						
							| 
									
										
										
										
											2024-06-30 19:07:38 +01:00
										 |  |  |   sig { params(args: Integer).returns(Formula) } | 
					
						
							| 
									
										
										
										
											2015-01-04 21:37:27 -05:00
										 |  |  |   def f(*args) | 
					
						
							| 
									
										
										
										
											2023-03-04 12:25:08 -08:00
										 |  |  |     to_s.f(*args) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-21 14:34:55 -07:00
										 |  |  |   # @!visibility private | 
					
						
							| 
									
										
										
										
											2024-06-30 19:07:38 +01:00
										 |  |  |   sig { params(config: T.nilable(T::Hash[Symbol, T.untyped])).returns(Cask::Cask) } | 
					
						
							| 
									
										
										
										
											2023-03-04 12:25:08 -08:00
										 |  |  |   def c(config: nil) | 
					
						
							| 
									
										
										
										
											2024-03-07 16:20:20 +00:00
										 |  |  |     to_s.c(config:) | 
					
						
							| 
									
										
										
										
											2012-08-30 22:54:24 -04:00
										 |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 22:41:47 -05:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2024-03-21 10:39:08 -07:00
										 |  |  |   module DevCmd | 
					
						
							|  |  |  |     class Irb < AbstractCommand | 
					
						
							|  |  |  |       cmd_args do | 
					
						
							|  |  |  |         description <<~EOS | 
					
						
							|  |  |  |           Enter the interactive Homebrew Ruby shell. | 
					
						
							|  |  |  |         EOS | 
					
						
							|  |  |  |         switch "--examples", | 
					
						
							|  |  |  |                description: "Show several examples." | 
					
						
							|  |  |  |         switch "--pry", | 
					
						
							|  |  |  |                env:         :pry, | 
					
						
							|  |  |  |                description: "Use Pry instead of IRB. Implied if `HOMEBREW_PRY` is set." | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       # work around IRB modifying ARGV. | 
					
						
							|  |  |  |       sig { params(argv: T.nilable(T::Array[String])).void } | 
					
						
							|  |  |  |       def initialize(argv = nil) = super(argv || ARGV.dup.freeze) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       sig { override.void } | 
					
						
							|  |  |  |       def run | 
					
						
							|  |  |  |         clean_argv | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if args.examples? | 
					
						
							|  |  |  |           puts <<~EOS | 
					
						
							|  |  |  |             'v8'.f # => instance of the v8 formula | 
					
						
							|  |  |  |             :hub.f.latest_version_installed? | 
					
						
							|  |  |  |             :lua.f.methods - 1.methods | 
					
						
							|  |  |  |             :mpd.f.recursive_dependencies.reject(&:installed?) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             'vlc'.c # => instance of the vlc cask | 
					
						
							| 
									
										
											  
											
												livecheck: clarify livecheckable language
Formulae, casks, and resources have a `#livecheckable?` method that
indicates whether they contain a `livecheck` block. This is intended
to be read as "has a livecheckable?", not "is livecheckable?" (as
livecheck can find versions for some packages/resources without a
`livecheck` block). Unfortunately, correct understanding of this
method's behavior [outside of documentation] relies on historical
knowledge that few people possess, so this is often confusing to
anyone who hasn't been working on livecheck since 2020.
In the olden days, a "livecheckable" was a Ruby file containing a
`livecheck` block (originally a hash) with a filename that
corresponded to a related formula. The `livecheck` blocks in
livecheckable files were integrated into their respective formulae in
August 2020, so [first-party] livecheckables ceased to exist at that
time. From that point forward, we simply referred to these as
`livecheck` blocks.
With that in mind, this clarifies the situation by replacing
"livecheckable" language. This includes renaming `#livecheckable?` to
`#livecheck_defined?`, replacing usage of "livecheckable" as a noun
with "`livecheck` block", replacing "livecheckable" as a boolean with
"livecheck_defined", and replacing incorrect usage of "livecheckable"
as an adjective with "checkable".
											
										 
											2024-11-27 18:20:56 -05:00
										 |  |  |             :tsh.c.livecheck_defined? | 
					
						
							| 
									
										
										
										
											2024-03-21 10:39:08 -07:00
										 |  |  |           EOS | 
					
						
							|  |  |  |           return | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if args.pry? | 
					
						
							|  |  |  |           Homebrew.install_bundler_gems!(groups: ["pry"]) | 
					
						
							|  |  |  |           require "pry" | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |           require "irb" | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         require "keg" | 
					
						
							|  |  |  |         require "cask" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ohai "Interactive Homebrew Shell", "Example commands available with: `brew irb --examples`" | 
					
						
							|  |  |  |         if args.pry? | 
					
						
							|  |  |  |           Pry.config.should_load_rc = false # skip loading .pryrc | 
					
						
							|  |  |  |           Pry.config.history_file = "#{Dir.home}/.brew_pry_history" | 
					
						
							|  |  |  |           Pry.config.prompt_name = "brew" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           Pry.start | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |           ENV["IRBRC"] = (HOMEBREW_LIBRARY_PATH/"brew_irbrc").to_s | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           IRB.start | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       private | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       # Remove the `--debug`, `--verbose` and `--quiet` options which cause problems | 
					
						
							|  |  |  |       # for IRB and have already been parsed by the CLI::Parser. | 
					
						
							| 
									
										
										
										
											2024-06-30 19:07:38 +01:00
										 |  |  |       sig { returns(T.nilable(T::Array[Symbol])) } | 
					
						
							| 
									
										
										
										
											2024-03-21 10:39:08 -07:00
										 |  |  |       def clean_argv | 
					
						
							|  |  |  |         global_options = Homebrew::CLI::Parser | 
					
						
							|  |  |  |                          .global_options | 
					
						
							|  |  |  |                          .flat_map { |options| options[0..1] } | 
					
						
							|  |  |  |         ARGV.reject! { |arg| global_options.include?(arg) } | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2018-03-25 17:48:22 +05:30
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2018-07-30 18:25:38 +05:30
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2012-08-06 14:41:55 -04:00
										 |  |  | end |