From ed7ed6262f13cc854021bf48ed3f1207b1164e17 Mon Sep 17 00:00:00 2001 From: Ned Palacios Date: Sun, 24 May 2020 20:25:29 +0800 Subject: [PATCH] vpm: use current folder v.mod, if no args provided in `v install` --- cmd/tools/vpm.v | 12 +++++++++++- cmd/v/help/install.txt | 8 +++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cmd/tools/vpm.v b/cmd/tools/vpm.v index dade7f7ca4..de839b89da 100644 --- a/cmd/tools/vpm.v +++ b/cmd/tools/vpm.v @@ -5,6 +5,7 @@ import os.cmdline import net.http import json import vhelp +import v.vmod const ( default_vpm_server_urls = ['https://vpm.best', 'https://vpm.vlang.io'] @@ -49,7 +50,7 @@ fn main() { exit(5) } vpm_command := params[0] - module_names := params[1..] + mut module_names := params[1..] ensure_vmodules_dir_exist() // println('module names: ') println(module_names) match vpm_command { @@ -60,6 +61,15 @@ fn main() { vpm_search(module_names) } 'install' { + if module_names.len == 0 && os.exists('./v.mod') { + println('Detected v.mod file inside the project directory. Using it...') + manifest := vmod.from_file('./v.mod') or { + panic(err) + } + + module_names = manifest.dependencies + } + vpm_install(module_names) } 'update' { diff --git a/cmd/v/help/install.txt b/cmd/v/help/install.txt index be6e4a9a1a..a0456e3f07 100644 --- a/cmd/v/help/install.txt +++ b/cmd/v/help/install.txt @@ -1,7 +1,13 @@ Usage: v install module [module] [module] [...] ^^^^^^^^^^^^^ will install the modules you specified + +You can also do `v install` directly if you have dependencies stored +inside the `v.mod` file. This will automatically installs the modules +specified inside of it. + Options: -help - Show usage info. -verbose - Print more details about the performed operation. - -server-url - When doing network operations, use this vpm server. Can be given multiple times. + -server-url - When doing network operations, use this vpm server. + Can be given multiple times.