aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dev-cmd
diff options
context:
space:
mode:
authorMike McQuaid2018-02-28 11:36:23 +0000
committerMike McQuaid2018-02-28 11:36:23 +0000
commit2205f62ec672643b845579f8687b0372b256f485 (patch)
tree7cb071d7138feb1811fe2f700dba581c654cb554 /Library/Homebrew/dev-cmd
parent6302da37f66fe9bb04e95fe67e8529fe0086187d (diff)
downloadbrew-2205f62ec672643b845579f8687b0372b256f485.tar.bz2
irb: add pry support.
Make `brew irb` optionally support `pry`. While doing so, also make it a `dev-cmd`.
Diffstat (limited to 'Library/Homebrew/dev-cmd')
-rw-r--r--Library/Homebrew/dev-cmd/irb.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/Library/Homebrew/dev-cmd/irb.rb b/Library/Homebrew/dev-cmd/irb.rb
new file mode 100644
index 000000000..700cbe009
--- /dev/null
+++ b/Library/Homebrew/dev-cmd/irb.rb
@@ -0,0 +1,54 @@
+#: * `irb` [`--examples`] [`--pry`]:
+#: Enter the interactive Homebrew Ruby shell.
+#:
+#: If `--examples` is passed, several examples will be shown.
+#: If `--pry` is passed or HOMEBREW_PRY is set, pry will be
+#: used instead of irb.
+
+class Symbol
+ def f(*args)
+ Formulary.factory(to_s, *args)
+ end
+end
+
+class String
+ def f(*args)
+ Formulary.factory(self, *args)
+ end
+end
+
+module Homebrew
+ module_function
+
+ def irb
+ if ARGV.include? "--examples"
+ puts "'v8'.f # => instance of the v8 formula"
+ puts ":hub.f.installed?"
+ puts ":lua.f.methods - 1.methods"
+ puts ":mpd.f.recursive_dependencies.reject(&:installed?)"
+ return
+ end
+
+ if ARGV.pry?
+ Homebrew.install_gem_setup_path! "pry"
+ require "pry"
+ Pry.config.prompt_name = "brew"
+ else
+ require "irb"
+ end
+
+ require "formula"
+ require "keg"
+
+ $LOAD_PATH.unshift("#{HOMEBREW_LIBRARY_PATH}/cask/lib")
+ require "hbc"
+
+ ohai "Interactive Homebrew Shell"
+ puts "Example commands available with: brew irb --examples"
+ if ARGV.pry?
+ Pry.start
+ else
+ IRB.start
+ end
+ end
+end