69 lines
1.3 KiB
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: false
# frozen_string_literal: true
2019-04-17 18:25:08 +09:00
require "cli/parser"
2018-03-24 20:04:45 +05:30
2012-08-31 08:09:50 -04:00
class Symbol
def f(*args)
Formulary.factory(to_s, *args)
2012-08-31 08:09:50 -04:00
end
end
2017-02-23 06:04:32 +01:00
class String
def f(*args)
Formulary.factory(self, *args)
end
end
module Homebrew
2016-09-26 01:44:51 +02:00
module_function
def irb_args
2020-07-30 18:40:10 +02:00
Homebrew::CLI::Parser.new do
2018-09-28 21:39:52 +05:30
usage_banner <<~EOS
`irb` [<options>]
2018-09-28 21:39:52 +05:30
Enter the interactive Homebrew Ruby shell.
EOS
switch "--examples",
2019-04-30 08:44:35 +01:00
description: "Show several examples."
2018-10-02 19:54:22 +05:30
switch "--pry",
2019-04-30 08:44:35 +01:00
env: :pry,
description: "Use Pry instead of IRB. Implied if `HOMEBREW_PRY` is set."
end
end
def irb
2020-08-03 02:27:20 +01:00
# work around IRB modifying ARGV.
args = irb_args.parse(ARGV.dup.freeze)
2018-03-24 20:04:45 +05:30
if args.examples?
2014-06-19 19:13:45 -05:00
puts "'v8'.f # => instance of the v8 formula"
puts ":hub.f.latest_version_installed?"
2012-08-31 08:09:50 -04:00
puts ":lua.f.methods - 1.methods"
puts ":mpd.f.recursive_dependencies.reject(&:installed?)"
return
end
if args.pry?
Homebrew.install_gem_setup_path! "pry"
require "pry"
Pry.config.prompt_name = "brew"
else
require "irb"
end
require "formula"
require "keg"
2020-08-09 01:34:07 +02:00
require "cask"
ohai "Interactive Homebrew Shell"
puts "Example commands available with: brew irb --examples"
if args.pry?
Pry.start
else
IRB.start
end
end
end