From 4614ed4274bae9207927436d810c0062a9000ce5 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Mon, 19 Jun 2017 21:09:48 -0500 Subject: [CLI] Dont print defaults in the command printed with --verbose --- lib/bundler/cli.rb | 14 ++++++++++---- spec/bundler/cli_spec.rb | 5 +++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 838dcb3e08..99eaa00cf9 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -621,10 +621,16 @@ module Bundler def print_command return unless ENV["BUNDLE_POSTIT_TRAMPOLINING_VERSION"] || Bundler.ui.debug? _, _, config = @_initializer - current_command = config[:current_command].name - return if %w[exec version check platform show help].include?(current_command) - command = ["bundle", current_command] + args - command << Thor::Options.to_switches(options) + current_command = config[:current_command] + command_name = current_command.name + return if %w[exec version check platform show help].include?(command_name) + command = ["bundle", command_name] + args + options_to_print = options.dup + options_to_print.delete_if do |k, v| + next unless o = current_command.options[k] + o.default == v + end + command << Thor::Options.to_switches(options_to_print).strip command.reject!(&:empty?) Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler::VERSION}" end diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb index f893e7799f..beec88b8a6 100644 --- a/spec/bundler/cli_spec.rb +++ b/spec/bundler/cli_spec.rb @@ -59,6 +59,11 @@ RSpec.describe "bundle executable" do bundle! "config", :verbose => true expect(out).to start_with("Running `bundle config --verbose` with bundler #{Bundler::VERSION}") end + + it "doesn't print defaults" do + install_gemfile! "", :verbose => true + expect(out).to start_with("Running `bundle install --verbose --retry 0 --no-color` with bundler #{Bundler::VERSION}") + end end describe "printing the outdated warning" do -- cgit v1.2.1