vpm search: mark modules that are already installed (#6657)

pull/6659/head
Lukas Neubert 2020-10-20 23:02:17 +02:00 committed by GitHub
parent 21db4b338b
commit f3de2cea7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -115,6 +115,7 @@ fn vpm_search(keywords []string) {
exit(2) exit(2)
} }
modules := get_all_modules() modules := get_all_modules()
installed_modules := get_installed_modules()
joined := search_keys.join(', ') joined := search_keys.join(', ')
mut index := 0 mut index := 0
for mod in modules { for mod in modules {
@ -131,16 +132,19 @@ fn vpm_search(keywords []string) {
// in case the author isn't present // in case the author isn't present
if parts.len == 1 { if parts.len == 1 {
parts << parts[0] parts << parts[0]
parts[0] = '' parts[0] = ' '
} else {
parts[0] = ' by ${parts[0]} '
} }
println('${index}. ${parts[1]} by ${parts[0]} [$mod]') installed := if mod in installed_modules { ' (installed)' } else { '' }
println('${index}. ${parts[1]}${parts[0]}[$mod]$installed')
break break
} }
} }
if index == 0 { if index == 0 {
println('No module(s) found for "$joined"') println('No module(s) found for "$joined"')
} else { } else {
println('\nUse "v install author_name.module_name" to install the module') println('\nUse "v install author_name.module_name" to install the module.')
} }
} }