def uninstall
list = Gem::Specification.find_all_by_name(@gem, @version)
if list.empty? then
raise Gem::InstallError, "gem #{@gem.inspect} is not installed"
elsif list.size > 1 and @force_all then
remove_all list
elsif list.size > 1 then
gem_names = list.collect {|gem| gem.full_name} + ["All versions"]
say
_, index = choose_from_list "Select gem to uninstall:", gem_names
if index == list.size then
remove_all list
elsif index >= 0 && index < list.size then
uninstall_gem list[index]
else
say "Error: must enter a number [1-#{list.size+1}]"
end
else
uninstall_gem list.first
end
end