From 698b247ed83a0f03e86c6d6954c380b9eeab8060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sat, 30 Mar 2019 11:36:43 +0100 Subject: Remove `bundle show` from bundler 3 --- lib/bundler/cli.rb | 55 +++++++++++++++++++++++----------------------- spec/commands/show_spec.rb | 2 +- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 3dc90c04dc..d11172ed44 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -282,35 +282,38 @@ module Bundler end end - desc "show GEM [OPTIONS]", "Shows all gems that are part of the bundle, or the path to a given gem" - long_desc <<-D - Show lists the names and versions of all gems that are required by your Gemfile. - Calling show with [GEM] will list the exact location of that gem on your machine. - D - method_option "paths", :type => :boolean, - :banner => "List the paths of all gems that are required by your Gemfile." - method_option "outdated", :type => :boolean, - :banner => "Show verbose output including whether gems are outdated." - def show(gem_name = nil) - if ARGV[0] == "show" - rest = ARGV[1..-1] - - new_command = rest.find {|arg| !arg.start_with?("--") } ? "info" : "list" - - new_arguments = rest.map do |arg| - next arg if arg != "--paths" - next "--path" if new_command == "info" - end + unless Bundler.feature_flag.list_command? + desc "show GEM [OPTIONS]", "Shows all gems that are part of the bundle, or the path to a given gem" + long_desc <<-D + Show lists the names and versions of all gems that are required by your Gemfile. + Calling show with [GEM] will list the exact location of that gem on your machine. + D + method_option "paths", :type => :boolean, + :banner => "List the paths of all gems that are required by your Gemfile." + method_option "outdated", :type => :boolean, + :banner => "Show verbose output including whether gems are outdated." + def show(gem_name = nil) + if ARGV[0] == "show" + rest = ARGV[1..-1] + + new_command = rest.find {|arg| !arg.start_with?("--") } ? "info" : "list" - old_argv = ARGV.join(" ") - new_argv = [new_command, *new_arguments.compact].join(" ") + new_arguments = rest.map do |arg| + next arg if arg != "--paths" + next "--path" if new_command == "info" + end - Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`") + old_argv = ARGV.join(" ") + new_argv = [new_command, *new_arguments.compact].join(" ") + + Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`") + end + require "bundler/cli/show" + Show.new(options, gem_name).run end - require "bundler/cli/show" - Show.new(options, gem_name).run + + map %w[list] => "show" end - # TODO: 2.0 remove `bundle show` if Bundler.feature_flag.list_command? desc "list", "List all gems in the bundle" @@ -324,8 +327,6 @@ module Bundler end map %w[ls] => "list" - else - map %w[list] => "show" end desc "info GEM [OPTIONS]", "Show information for the given gem" diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb index d79ac2704f..6634a3f7ed 100644 --- a/spec/commands/show_spec.rb +++ b/spec/commands/show_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle show" do +RSpec.describe "bundle show", :bundler => "< 3" do context "with a standard Gemfile" do before :each do install_gemfile <<-G -- cgit v1.2.1