Skip to content

Commit a3427c7

Browse files
authored
Merge pull request #4023 from landongrindheim/move-description-into-query-command
Omit deprecated commands from command help output
2 parents 3e71d3f + 7b3012d commit a3427c7

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,13 @@ def initialize(name = 'query',
3131

3232
add_query_options
3333
end
34+
35+
def description # :nodoc:
36+
<<-EOF
37+
The query command is the basis for the list and search commands.
38+
39+
You should really use the list and search commands instead. This command
40+
is too hard to use.
41+
EOF
42+
end
3443
end

lib/rubygems/query_utils.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,6 @@ def defaults_str # :nodoc:
5757
"--local --name-matches // --no-details --versions --no-installed"
5858
end
5959

60-
def description # :nodoc:
61-
<<-EOF
62-
The query command is the basis for the list and search commands.
63-
64-
You should really use the list and search commands instead. This command
65-
is too hard to use.
66-
EOF
67-
end
68-
6960
def execute
7061
gem_names = Array(options[:name])
7162

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)