summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2017-08-11 14:07:47 +0000
committerThe Bundler Bot <bot@bundler.io>2017-08-11 14:07:47 +0000
commit619dc63a797986e49e19d48ceae3b249fa3d8a5f (patch)
treeb10f82368cb10468ad961c158d03629223153220 /lib
parent14e7da3dbecc26fb92411d64287dac9f22b5e7fc (diff)
parent5d22dbe1d49826cc5f7108d95e6981b1ed15c5d8 (diff)
downloadbundler-619dc63a797986e49e19d48ceae3b249fa3d8a5f.tar.gz
Auto merge of #5920 - bundler:colby/bundler-list, r=segiddins
implement new list command ### What was the end-user problem that led to this PR? We're removing the `bundle show` command (which has been replaced with `bundle info`) but we should probably still have a command to list the gems in the bundle. ### What was your diagnosis of the problem? `bundle show` has been marked as deprecated but a replacement for listing gems does not yet exist ### What is your fix for the problem, implemented in this PR? Add a new `bundle list` (including `ls` alias) that prints the gems in the bundle, this was taken from #4754
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli.rb14
-rw-r--r--lib/bundler/cli/list.rb22
-rw-r--r--lib/bundler/feature_flag.rb1
-rw-r--r--lib/bundler/settings.rb1
4 files changed, 37 insertions, 1 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 0d559a8f76..2adbac403e 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -261,7 +261,19 @@ module Bundler
Show.new(options, gem_name).run
end
# TODO: 2.0 remove `bundle show`
- map %w[list] => "show"
+
+ if Bundler.feature_flag.list_command?
+ desc "list", "List all gems in the bundle"
+ method_option "name-only", :type => :boolean, :banner => "print only the gem names"
+ def list
+ require "bundler/cli/list"
+ List.new(options).run
+ end
+
+ map %w[ls] => "list"
+ else
+ map %w[list] => "show"
+ end
desc "info GEM [OPTIONS]", "Show information for the given gem"
method_option "path", :type => :boolean, :banner => "Print full path to gem"
diff --git a/lib/bundler/cli/list.rb b/lib/bundler/cli/list.rb
new file mode 100644
index 0000000000..b5e7c1e650
--- /dev/null
+++ b/lib/bundler/cli/list.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+module Bundler
+ class CLI::List
+ def initialize(options)
+ @options = options
+ end
+
+ def run
+ specs = Bundler.load.specs.reject {|s| s.name == "bundler" }.sort_by(&:name)
+ return specs.each {|s| Bundler.ui.info s.name } if @options["name-only"]
+
+ return Bundler.ui.info "No gems in the Gemfile" if specs.empty?
+ Bundler.ui.info "Gems included by the bundle:"
+ specs.each do |s|
+ Bundler.ui.info " * #{s.name} (#{s.version}#{s.git_version})"
+ end
+
+ Bundler.ui.info "Use `bundle info` to print more detailed information about a gem"
+ end
+ end
+end
diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb
index 39e2be978c..07d11418be 100644
--- a/lib/bundler/feature_flag.rb
+++ b/lib/bundler/feature_flag.rb
@@ -49,6 +49,7 @@ module Bundler
settings_flag(:unlock_source_unlocks_spec) { !bundler_2_mode? }
settings_flag(:update_requires_all_flag) { bundler_2_mode? }
settings_flag(:default_install_uses_path) { bundler_2_mode? }
+ settings_flag(:list_command) { bundler_2_mode? }
settings_option(:default_cli_command) { bundler_2_mode? ? :cli_help : :install }
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index fc59631608..a23264ecf4 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -34,6 +34,7 @@ module Bundler
global_gem_cache
ignore_messages
init_gems_rb
+ list_command
lockfile_uses_separate_rubygems_sources
major_deprecations
no_install