From 6d788654e1d2c6108349d9e7f853f57363917ce4 Mon Sep 17 00:00:00 2001 From: Lukas Neubert Date: Thu, 2 Jul 2020 18:20:42 +0200 Subject: [PATCH] vpm: fixes with underscores for install and search (#5623) --- cmd/tools/vpm.v | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/tools/vpm.v b/cmd/tools/vpm.v index a28ef7a418..8c4d2639f4 100644 --- a/cmd/tools/vpm.v +++ b/cmd/tools/vpm.v @@ -88,20 +88,21 @@ fn main() { } fn vpm_search(keywords []string) { + search_keys := keywords.map(it.replace('_', '-')) if settings.is_help { vhelp.show_topic('search') exit(0) } - if keywords.len == 0 { + if search_keys.len == 0 { println(' v search requires *at least one* keyword') exit(2) } modules := get_all_modules() - joined := keywords.join(', ') + joined := search_keys.join(', ') mut index := 0 for mod in modules { // TODO for some reason .filter results in substr error, so do it manually - for k in keywords { + for k in search_keys { if !mod.contains(k) { continue } @@ -119,9 +120,11 @@ fn vpm_search(keywords []string) { break } } - println('\nUse "v install author_name.module_name" to install the module') + if index == 0 { println('No module(s) found for "$joined"') + } else { + println('\nUse "v install author_name.module_name" to install the module') } } @@ -136,7 +139,7 @@ fn vpm_install(module_names []string) { } mut errors := 0 for n in module_names { - name := n.trim_space() + name := n.trim_space().replace('_', '-') mod := get_module_meta_info(name) or { errors++ println('Errors while retrieving meta data for module $name:')