From c93467bca5275e3085dc0a1301cc63ea71f5c093 Mon Sep 17 00:00:00 2001 From: Lukas Neubert Date: Mon, 20 Jul 2020 16:39:37 +0200 Subject: [PATCH] vpm: add list command (#5888) --- cmd/tools/vpm.v | 16 +++++++++++++++- cmd/v/help/default.txt | 3 ++- cmd/v/v.v | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/cmd/tools/vpm.v b/cmd/tools/vpm.v index acec3e7c32..6d9c11f1b5 100644 --- a/cmd/tools/vpm.v +++ b/cmd/tools/vpm.v @@ -9,7 +9,7 @@ import v.vmod const ( 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'] supported_vcs_systems = ['git', 'hg'] supported_vcs_folders = ['.git', '.hg'] @@ -79,6 +79,9 @@ fn main() { 'outdated' { vpm_outdated() } + 'list' { + vpm_list() + } 'remove' { 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) { if settings.is_help { vhelp.show_topic('remove') diff --git a/cmd/v/help/default.txt b/cmd/v/help/default.txt index c8026e8f73..fea94b43de 100644 --- a/cmd/v/help/default.txt +++ b/cmd/v/help/default.txt @@ -31,7 +31,8 @@ V supports the following commands: remove Remove a module that was installed from VPM. search Search for a 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: 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). diff --git a/cmd/v/v.v b/cmd/v/v.v index d4fa7320b1..f4c73f1569 100644 --- a/cmd/v/v.v +++ b/cmd/v/v.v @@ -70,7 +70,7 @@ fn main() { println('Translating C to V will be available in V 0.3') return } - 'search', 'install', 'update', 'outdated', 'remove' { + 'search', 'install', 'update', 'outdated', 'list', 'remove' { util.launch_tool(prefs.is_verbose, 'vpm', os.args[1..]) return }