vpm: add list command (#5888)

pull/5895/head
Lukas Neubert 2020-07-20 16:39:37 +02:00 committed by GitHub
parent c60948e52e
commit c93467bca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View File

@ -9,7 +9,7 @@ import v.vmod
const ( const (
default_vpm_server_urls = ['https://vpm.best', 'https://vpm.vlang.io'] default_vpm_server_urls = ['https://vpm.best', 'https://vpm.vlang.io']
valid_vpm_commands = ['help', 'search', 'install', 'update', 'outdated', 'remove'] valid_vpm_commands = ['help', 'search', 'install', 'update', 'outdated', 'list', 'remove']
excluded_dirs = ['cache', 'vlib'] excluded_dirs = ['cache', 'vlib']
supported_vcs_systems = ['git', 'hg'] supported_vcs_systems = ['git', 'hg']
supported_vcs_folders = ['.git', '.hg'] supported_vcs_folders = ['.git', '.hg']
@ -79,6 +79,9 @@ fn main() {
'outdated' { 'outdated' {
vpm_outdated() vpm_outdated()
} }
'list' {
vpm_list()
}
'remove' { 'remove' {
vpm_remove(module_names) vpm_remove(module_names)
} }
@ -283,6 +286,17 @@ fn vpm_outdated() {
} }
} }
fn vpm_list() {
module_names := get_installed_modules()
if module_names.len == 0 {
println('You have no modules installed.')
exit(0)
}
for mod in module_names {
println(mod)
}
}
fn vpm_remove(module_names []string) { fn vpm_remove(module_names []string) {
if settings.is_help { if settings.is_help {
vhelp.show_topic('remove') vhelp.show_topic('remove')

View File

@ -31,7 +31,8 @@ V supports the following commands:
remove Remove a module that was installed from VPM. remove Remove a module that was installed from VPM.
search Search for a module from VPM. search Search for a module from VPM.
update Update an installed module from VPM. update Update an installed module from VPM.
outdated List installed modules that need updates. list List all installed modules.
outdated Show installed modules that need updates.
* Others: * Others:
build Build a V code in the provided path (the default, so you can skip the word `build`). build Build a V code in the provided path (the default, so you can skip the word `build`).
translate Translate C code to V (coming soon in 0.3). translate Translate C code to V (coming soon in 0.3).

View File

@ -70,7 +70,7 @@ fn main() {
println('Translating C to V will be available in V 0.3') println('Translating C to V will be available in V 0.3')
return return
} }
'search', 'install', 'update', 'outdated', 'remove' { 'search', 'install', 'update', 'outdated', 'list', 'remove' {
util.launch_tool(prefs.is_verbose, 'vpm', os.args[1..]) util.launch_tool(prefs.is_verbose, 'vpm', os.args[1..])
return return
} }