Skip to content

Commit

Permalink
Omit deprecated gems from gem help commands
Browse files Browse the repository at this point in the history
This change came about through discussion with David Rodgriguez. We've
been deliberating whether to document the deprecated status of commands.
I looked for examples in the OSS community and found that there's a lot
of inconsistency around documenting deprecated items. Ruby does and
doesn't do it. Rails seems to do it. Elixir seems to do it. It's not a
settled matter.

Ultimately, the decision was to remove the deprecated commands from the
`help commands` command.
  • Loading branch information
landongrindheim committed Oct 21, 2020
1 parent 976e87c commit 11d262c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/rubygems/commands/help_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ def show_commands # :nodoc:
@command_manager.command_names.each do |cmd_name|
command = @command_manager[cmd_name]

next if command.deprecated?

summary =
if command
command.summary
Expand Down
15 changes: 14 additions & 1 deletion test/rubygems/test_gem_commands_help_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def test_gem_help_commands

util_gem 'commands' do |out, err|
mgr.command_names.each do |cmd|
assert_match(/\s+#{cmd}\s+\S+/, out)
unless mgr[cmd].deprecated?
assert_match(/\s+#{cmd}\s+\S+/, out)
end
end

if Gem::HAVE_OPENSSL
Expand All @@ -51,6 +53,17 @@ def test_gem_help_commands
end
end

def test_gem_help_commands_omits_deprecated_commands
mgr = Gem::CommandManager.new

util_gem 'commands' do |out, err|
deprecated_commands = mgr.command_names.select {|cmd| mgr[cmd].deprecated? }
deprecated_commands.each do |cmd|
refute_match(/\s+#{cmd}\s+\S+/, out)
end
end
end

def test_gem_no_args_shows_help
util_gem do |out, err|
assert_match(/Usage:/, out)
Expand Down

0 comments on commit 11d262c

Please sign in to comment.