1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vpm: use current folder v.mod, if no args provided in v install

This commit is contained in:
Ned Palacios 2020-05-24 20:25:29 +08:00 committed by GitHub
parent ddcb5f7da3
commit ed7ed6262f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -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' {

View File

@ -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.