vpm: fixes with underscores for install and search (#5623)
							parent
							
								
									68ac8fde26
								
							
						
					
					
						commit
						6d788654e1
					
				|  | @ -88,20 +88,21 @@ fn main() { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn vpm_search(keywords []string) { | fn vpm_search(keywords []string) { | ||||||
|  | 	search_keys := keywords.map(it.replace('_', '-')) | ||||||
| 	if settings.is_help { | 	if settings.is_help { | ||||||
| 		vhelp.show_topic('search') | 		vhelp.show_topic('search') | ||||||
| 		exit(0) | 		exit(0) | ||||||
| 	} | 	} | ||||||
| 	if keywords.len == 0 { | 	if search_keys.len == 0 { | ||||||
| 		println('  v search requires *at least one* keyword') | 		println('  v search requires *at least one* keyword') | ||||||
| 		exit(2) | 		exit(2) | ||||||
| 	} | 	} | ||||||
| 	modules := get_all_modules() | 	modules := get_all_modules() | ||||||
| 	joined := keywords.join(', ') | 	joined := search_keys.join(', ') | ||||||
| 	mut index := 0 | 	mut index := 0 | ||||||
| 	for mod in modules { | 	for mod in modules { | ||||||
| 		// TODO for some reason .filter results in substr error, so do it manually
 | 		// 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) { | 			if !mod.contains(k) { | ||||||
| 				continue | 				continue | ||||||
| 			} | 			} | ||||||
|  | @ -119,9 +120,11 @@ fn vpm_search(keywords []string) { | ||||||
| 			break | 			break | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	println('\nUse "v install author_name.module_name" to install the module') | 
 | ||||||
| 	if index == 0 { | 	if index == 0 { | ||||||
| 		println('No module(s) found for "$joined"') | 		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 | 	mut errors := 0 | ||||||
| 	for n in module_names { | 	for n in module_names { | ||||||
| 		name := n.trim_space() | 		name := n.trim_space().replace('_', '-') | ||||||
| 		mod := get_module_meta_info(name) or { | 		mod := get_module_meta_info(name) or { | ||||||
| 			errors++ | 			errors++ | ||||||
| 			println('Errors while retrieving meta data for module $name:') | 			println('Errors while retrieving meta data for module $name:') | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue