lib/bundler/cli.rb in bundler-1.14.6 vs lib/bundler/cli.rb in bundler-1.15.0.pre.1
- old
+ new
@@ -11,23 +11,26 @@
super
rescue Exception => e
Bundler.ui = UI::Shell.new
raise e
ensure
+ warn_on_outdated_bundler
Bundler::SharedHelpers.print_major_deprecations!
end
def self.dispatch(*)
super {|i| i.send(:print_command) }
end
def initialize(*args)
super
- Bundler.reset!
custom_gemfile = options[:gemfile] || Bundler.settings[:gemfile]
- ENV["BUNDLE_GEMFILE"] = File.expand_path(custom_gemfile) if custom_gemfile && !custom_gemfile.empty?
+ if custom_gemfile && !custom_gemfile.empty?
+ ENV["BUNDLE_GEMFILE"] = File.expand_path(custom_gemfile)
+ Bundler.reset_paths!
+ end
Bundler.settings[:retry] = options[:retry] if options[:retry]
current_cmd = args.last[:current_command].name
auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
@@ -82,10 +85,13 @@
else
super
end
end
+ # Ensure `bundle help --no-color` is valid
+ all_commands["help"].disable_class_options = false
+
def self.handle_no_command_error(command, has_namespace = $thor_runner)
if Bundler.feature_flag.plugins? && Bundler::Plugin.command?(command)
return Bundler::Plugin.exec_command(command, ARGV[1..-1])
end
@@ -236,10 +242,17 @@
Show.new(options, gem_name).run
end
# TODO: 2.0 remove `bundle list`
map %w(list) => "show"
+ desc "info GEM [OPTIONS]", "Show information for the given gem"
+ method_option "path", :type => :boolean, :banner => "Print full path to gem"
+ def info(gem_name)
+ require "bundler/cli/info"
+ Info.new(options, gem_name).run
+ end
+
desc "binstubs GEM [OPTIONS]", "Install the binstubs of the listed gem"
long_desc <<-D
Generate binstubs for executables in [GEM]. Binstubs are put into bin,
or the --binstubs directory if one has been set. Calling binstubs with [GEM [GEM]]
will create binstubs for all given gems.
@@ -253,10 +266,23 @@
def binstubs(*gems)
require "bundler/cli/binstubs"
Binstubs.new(options, gems).run
end
+ desc "add GEM VERSION", "Add gem to Gemfile and run bundle install"
+ long_desc <<-D
+ Adds the specified gem to Gemfile (if valid) and run 'bundle install' in one step.
+ D
+ method_option "version", :aliases => "-v", :type => :string
+ method_option "group", :aliases => "-g", :type => :string
+ method_option "source", :aliases => "-s", :type => :string
+
+ def add(gem_name)
+ require "bundler/cli/add"
+ Add.new(options.dup, gem_name).run
+ end
+
desc "outdated GEM [OPTIONS]", "list installed gems with newer versions available"
long_desc <<-D
Outdated lists the names and versions of gems that have a newer version available
in the given source. Calling outdated with [GEM [GEM]] will only check for newer
versions of the given gems. Prerelease gems are ignored by default. If your gems
@@ -345,10 +371,11 @@
If a global setting is superceded by local configuration, this command
will show the current value, as well as any superceded values and
where they were specified.
D
+ method_option "parseable", :type => :boolean, :banner => "Use minimal formatting for more parseable output"
def config(*args)
require "bundler/cli/config"
Config.new(options, args, self).run
end
@@ -459,14 +486,18 @@
require "bundler/cli/platform"
Platform.new(options).run
end
desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile"
+ method_option "source", :type => :string, :banner =>
+ "Install gem from the given source"
+ method_option "group", :type => :string, :banner =>
+ "Install gem into a bundler group"
def inject(name, version)
SharedHelpers.major_deprecation "The `inject` command has been replaced by the `add` command"
require "bundler/cli/inject"
- Inject.new(options, name, version).run
+ Inject.new(options.dup, name, version).run
end
desc "lock", "Creates a lockfile without installing"
method_option "update", :type => :array, :lazy_default => true, :banner =>
"ignore the existing lockfile, update all gems by default, or update list of given gems"
@@ -515,10 +546,22 @@
def doctor
require "bundler/cli/doctor"
Doctor.new(options).run
end
+ desc "issue", "Learn how to report an issue in Bundler"
+ def issue
+ require "bundler/cli/issue"
+ Issue.new.run
+ end
+
+ desc "pristine", "Restores installed gems to pristine condition from files located in the gem cache. Gem installed from a git repository will be issued `git checkout --force`."
+ def pristine
+ require "bundler/cli/pristine"
+ Pristine.new.run
+ end
+
if Bundler.feature_flag.plugins?
require "bundler/cli/plugin"
desc "plugin SUBCOMMAND ...ARGS", "manage the bundler plugins"
subcommand "plugin", Plugin
end
@@ -577,7 +620,28 @@
command = ["bundle", current_command] + args
command << Thor::Options.to_switches(options)
command.reject!(&:empty?)
Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler::VERSION}"
end
+
+ def self.warn_on_outdated_bundler
+ return if Bundler.settings[:disable_version_check]
+
+ latest = Fetcher::CompactIndex.
+ new(nil, Source::Rubygems::Remote.new(URI("https://rubygems.org")), nil).
+ send(:compact_index_client).
+ instance_variable_get(:@cache).
+ dependencies("bundler").
+ map {|d| Gem::Version.new(d.first) }.
+ max
+ return unless latest
+
+ current = Gem::Version.new(VERSION)
+ return if current >= latest
+
+ Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\nTo update, run `gem install bundler#{" --pre" if latest.prerelease?}`"
+ rescue
+ nil
+ end
+ private_class_method :warn_on_outdated_bundler
end
end