Skip to content

Commit

Permalink
Merge pull request #3867 from rubygems/fix-cleanup-flag-name
Browse files Browse the repository at this point in the history
Make --dry-run flag consistent across rubygems commands
  • Loading branch information
deivid-rodriguez committed Sep 3, 2020
2 parents dc133dc + 38230a7 commit 8bf3994
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/rubygems/commands/cleanup_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ def initialize
:force => false, :install_dir => Gem.dir,
:check_dev => true

add_option('-n', '-d', '--dryrun',
add_option('-n', '-d', '--dry-run',
'Do not uninstall gems') do |value, options|
options[:dryrun] = true
end

add_option(:Deprecated, '--dryrun',
'Do not uninstall gems') do |value, options|
options[:dryrun] = true
end
deprecate_option('--dryrun', extra_msg: 'Use --dry-run instead')

add_option('-D', '--[no-]check-development',
'Check development dependencies while uninstalling',
'(default: true)') do |value, options|
Expand All @@ -41,7 +47,7 @@ def arguments # :nodoc:
end

def defaults_str # :nodoc:
"--no-dryrun"
"--no-dry-run"
end

def description # :nodoc:
Expand Down
13 changes: 12 additions & 1 deletion test/rubygems/test_gem_commands_cleanup_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,21 @@ def test_handle_options_d
end

def test_handle_options_dry_run
@cmd.handle_options %w[--dryrun]
@cmd.handle_options %w[--dry-run]
assert @cmd.options[:dryrun]
end

def test_handle_options_deprecated_dry_run
use_ui @ui do
@cmd.handle_options %w[--dryrun]
assert @cmd.options[:dryrun]
end

assert_equal \
"WARNING: The \"--dryrun\" option has been deprecated and will be removed in future versions of Rubygems. Use --dry-run instead\n",
@ui.error
end

def test_handle_options_n
@cmd.handle_options %w[-n]
assert @cmd.options[:dryrun]
Expand Down

0 comments on commit 8bf3994

Please sign in to comment.