Skip to content

Commit 7b3012d

Browse files
Omit deprecated gems from gem help commands
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.
1 parent c91087c commit 7b3012d

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

lib/rubygems/commands/help_command.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ def show_commands # :nodoc:
332332
@command_manager.command_names.each do |cmd_name|
333333
command = @command_manager[cmd_name]
334334

335+
next if command.deprecated?
336+
335337
summary =
336338
if command
337339
command.summary

lib/rubygems/commands/query_command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def initialize(name = 'query',
3232
add_query_options
3333
end
3434

35-
def description
35+
def description # :nodoc:
3636
<<-EOF
3737
The query command is the basis for the list and search commands.
3838

test/rubygems/test_gem_commands_help_command.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def test_gem_help_commands
4040

4141
util_gem 'commands' do |out, err|
4242
mgr.command_names.each do |cmd|
43-
assert_match(/\s+#{cmd}\s+\S+/, out)
43+
unless mgr[cmd].deprecated?
44+
assert_match(/\s+#{cmd}\s+\S+/, out)
45+
end
4446
end
4547

4648
if Gem::HAVE_OPENSSL
@@ -51,6 +53,17 @@ def test_gem_help_commands
5153
end
5254
end
5355

56+
def test_gem_help_commands_omits_deprecated_commands
57+
mgr = Gem::CommandManager.new
58+
59+
util_gem 'commands' do |out, err|
60+
deprecated_commands = mgr.command_names.select {|cmd| mgr[cmd].deprecated? }
61+
deprecated_commands.each do |cmd|
62+
refute_match(/\s+#{cmd}\s+\S+/, out)
63+
end
64+
end
65+
end
66+
5467
def test_gem_no_args_shows_help
5568
util_gem do |out, err|
5669
assert_match(/Usage:/, out)

0 commit comments

Comments
 (0)