summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPostmodern <postmodern.mod3@gmail.com>2012-01-06 13:15:16 -0800
committerJonathan Allard <jonathan@allard.io>2013-09-02 11:19:48 -0400
commita550d0330e2e57e85e315b9667a78319d68bc5b2 (patch)
treec16ec147d253d9d06b5d2f6f8222f144657f4081
parentb89e304cab8c92c969b0a700e5e66c114f23e58d (diff)
downloadbundler-a550d0330e2e57e85e315b9667a78319d68bc5b2.tar.gz
Add support for IRB-alternatives (Pry and Ripl) to `bundle console`.
-rw-r--r--lib/bundler/cli.rb30
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 60f996700c..6bb1423767 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -634,13 +634,39 @@ module Bundler
end
end
+ CONSOLES = [
+ ['pry', :Pry],
+ ['ripl', :Ripl],
+ ['irb', :IRB]
+ ]
+
desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
def console(group = nil)
group ? Bundler.require(:default, *(group.split.map! {|g| g.to_sym })) : Bundler.require
ARGV.clear
- require 'irb'
- IRB.start
+ file, constant = CONSOLES.find do |file,constant|
+ begin
+ require(file) || true
+ rescue LoadError
+ false
+ end
+ end
+
+ unless constant
+ Bundler.ui.error "Could not load the Ruby console"
+ return
+ end
+
+ console = begin
+ Object.const_get(constant)
+ rescue NameError => e
+ Bundler.ui.error e.inspect
+ Bundler.ui.error "Could not load the #{file} console"
+ return
+ end
+
+ console.start
end
desc "version", "Prints the bundler's version information"