diff options
author | Postmodern <postmodern.mod3@gmail.com> | 2012-01-06 13:15:16 -0800 |
---|---|---|
committer | Jonathan Allard <jonathan@allard.io> | 2013-09-02 11:19:48 -0400 |
commit | a550d0330e2e57e85e315b9667a78319d68bc5b2 (patch) | |
tree | c16ec147d253d9d06b5d2f6f8222f144657f4081 | |
parent | b89e304cab8c92c969b0a700e5e66c114f23e58d (diff) | |
download | bundler-a550d0330e2e57e85e315b9667a78319d68bc5b2.tar.gz |
Add support for IRB-alternatives (Pry and Ripl) to `bundle console`.
-rw-r--r-- | lib/bundler/cli.rb | 30 |
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" |