1require 'rubygems/command' 2require 'rubygems/commands/query_command' 3 4## 5# An alternate to Gem::Commands::QueryCommand that searches for gems starting 6# with the the supplied argument. 7 8class Gem::Commands::ListCommand < Gem::Commands::QueryCommand 9 10 def initialize 11 super 'list', 'Display gems whose name starts with STRING' 12 13 remove_option('--name-matches') 14 end 15 16 def arguments # :nodoc: 17 "STRING start of gem name to look for" 18 end 19 20 def defaults_str # :nodoc: 21 "--local --no-details" 22 end 23 24 def usage # :nodoc: 25 "#{program_name} [STRING]" 26 end 27 28 def execute 29 string = get_one_optional_argument || '' 30 options[:name] = /^#{string}/i 31 super 32 end 33 34end 35 36