lib/bundler/cli.rb in bundler-1.0.0.beta.2 vs lib/bundler/cli.rb in bundler-1.0.0.beta.3
- old
+ new
@@ -7,17 +7,20 @@
module Bundler
class CLI < Thor
def initialize(*)
super
- Bundler.ui = UI::Shell.new(shell)
+ use_shell = options["no-color"] ? Thor::Shell::Basic.new : shell
+
+ Bundler.ui = UI::Shell.new(use_shell)
Gem::DefaultUserInteraction.ui = UI::RGProxy.new(Bundler.ui)
end
check_unknown_options! unless ARGV.include?("exec")
default_task :install
+ class_option "no-color", :type => :boolean, :banner => "Disable colorization in output"
desc "init", "Generates a Gemfile into the current working directory"
long_desc <<-D
Init generates a default Gemfile in the current working directory. When adding a
Gemfile to a gem with a gemspec, the --gemspec option will automatically add each
@@ -91,18 +94,21 @@
"Don't update the existing gem cache."
method_option "quiet", :type => :boolean, :banner =>
"Only output warnings and errors."
method_option "local", :type => :boolean, :banner =>
"Do not attempt to fetch gems remotely and use the gem cache instead"
+ method_option "binstubs", :type => :boolean, :banner =>
+ "Generate bin stubs for bundled gems to ./bin"
def install(path = nil)
opts = options.dup
opts[:without] ||= []
opts[:without].map! { |g| g.to_sym }
# Can't use Bundler.settings for this because settings needs gemfile.dirname
ENV['BUNDLE_GEMFILE'] = opts[:gemfile] if opts[:gemfile]
Bundler.settings[:path] = path if path
+ Bundler.settings[:bin] = 'bin' if opts[:binstubs]
Bundler.settings[:disable_shared_gems] = '1' if options["disable-shared-gems"] || path
Bundler.settings.without = opts[:without]
Bundler.ui.be_quiet! if opts[:quiet]
Installer.install(Bundler.root, Bundler.definition, opts)
@@ -126,11 +132,11 @@
def update(*gems)
sources = Array(options[:source])
if gems.empty? && sources.empty?
# We're doing a full update
- FileUtils.rm Bundler.root.join("Gemfile.lock")
+ FileUtils.rm_f Bundler.root.join("Gemfile.lock")
else
Bundler.definition(:gems => gems, :sources => sources)
end
Installer.install Bundler.root, Bundler.definition
@@ -228,16 +234,16 @@
end
end
desc "open GEM", "Opens the source directory of the given bundled gem"
def open(name)
- editor = [ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? }
+ editor = [ENV['BUNDLER_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? }
if editor
command = "#{editor} #{locate_gem(name)}"
success = system(command)
Bundler.ui.info "Could not run '#{command}'" unless success
else
- Bundler.ui.info("To open a bundled gem, set $EDITOR")
+ Bundler.ui.info("To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR")
end
end
desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
def console(group = nil)