1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
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

View File

@ -115,6 +115,7 @@ fn vpm_search(keywords []string) {
exit(2)
}
modules := get_all_modules()
installed_modules := get_installed_modules()
joined := search_keys.join(', ')
mut index := 0
for mod in modules {
@ -131,16 +132,19 @@ fn vpm_search(keywords []string) {
// in case the author isn't present
if parts.len == 1 {
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
}
}
if index == 0 {
println('No module(s) found for "$joined"')
} 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.')
}
}