Class: Homebrew::DevCmd::Irb

Inherits:
AbstractCommand show all
Defined in:
dev-cmd/irb.rb

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, parser

Constructor Details

#initialize(argv = nil) ⇒ void

work around IRB modifying ARGV.

Parameters:



45
# File 'dev-cmd/irb.rb', line 45

def initialize(argv = nil) = super(argv || ARGV.dup.freeze)

Instance Method Details

#runvoid

This method returns an undefined value.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'dev-cmd/irb.rb', line 48

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
      :tsh.c.livecheckable?
    EOS
    return
  end

  if args.pry?
    Homebrew.install_bundler_gems!(groups: ["pry"])
    require "pry"
  else
    require "irb"
  end

  require "formula"
  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