diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-03-20 21:30:31 +0100 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-04-05 09:26:27 +0200 |
commit | bdc78428589547aec003e965302f1fcf985f18fa (patch) | |
tree | 21fa6a66c52520c731009fb183037cdc4132af29 | |
parent | 54387d3586e910cc85f23c097c635d3e804722a8 (diff) | |
download | bundler-bdc78428589547aec003e965302f1fcf985f18fa.tar.gz |
Print a better messages on undocumented flags
Inform about complete removal when `bundle show --outdated` and `bundle
show --verbose`.
-rw-r--r-- | lib/bundler/cli.rb | 20 | ||||
-rw-r--r-- | spec/other/major_deprecation_spec.rb | 28 |
2 files changed, 40 insertions, 8 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index d11172ed44..c58d0875d5 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -296,17 +296,21 @@ module Bundler if ARGV[0] == "show" rest = ARGV[1..-1] - new_command = rest.find {|arg| !arg.start_with?("--") } ? "info" : "list" + if flag = rest.find{|arg| ["--verbose", "--outdated"].include?(arg) } + Bundler::SharedHelpers.major_deprecation(2, "the `#{flag}` flag to `bundle show` was undocumented and will be removed without replacement") + else + 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 + new_arguments = rest.map do |arg| + next arg if arg != "--paths" + next "--path" if new_command == "info" + end - old_argv = ARGV.join(" ") - new_argv = [new_command, *new_arguments.compact].join(" ") + 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}`") + Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`") + end end require "bundler/cli/show" Show.new(options, gem_name).run diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb index 6d3d55be0f..3d79a51b94 100644 --- a/spec/other/major_deprecation_spec.rb +++ b/spec/other/major_deprecation_spec.rb @@ -486,6 +486,34 @@ The :gist git source is deprecated, and will be removed in the future. Add this end end + context "with --outdated flag" do + before do + bundle! "show --outdated" + end + + it "does not print a deprecation warning", :bundler => "< 2" do + expect(deprecations).to be_empty + end + + it "prints a deprecation warning informing about its removal", :bundler => "2" do + expect(deprecations).to include("the `--outdated` flag to `bundle show` was undocumented and will be removed without replacement") + end + end + + context "with --verbose flag" do + before do + bundle! "show --verbose" + end + + it "does not print a deprecation warning", :bundler => "< 2" do + expect(deprecations).to be_empty + end + + it "prints a deprecation warning informing about its removal", :bundler => "2" do + expect(deprecations).to include("the `--verbose` flag to `bundle show` was undocumented and will be removed without replacement") + end + end + context "with a gem argument" do before do bundle! "show rack" |