v install: install multiple modules in one command: 'v install m1 m2 m3 …'

pull/1564/head
iRedMail 2019-08-10 18:21:31 +08:00 committed by Alexander Medvednikov
parent a0b583d8c8
commit c67783bcd1
2 changed files with 35 additions and 19 deletions

View File

@ -126,11 +126,12 @@ fn main() {
return return
} }
if 'install' in args { if 'install' in args {
mod := args.last() if args.len <= 3 {
if args.len != 3 || mod.len < 2 { println('usage: v install [module] [module] [...]')
println('usage: v install [module]')
return return
} }
names := args.slice(2, args.len)
vroot := os.dir(os.executable()) vroot := os.dir(os.executable())
vget := '$vroot/tools/vget' vget := '$vroot/tools/vget'
if true { if true {
@ -140,10 +141,9 @@ fn main() {
_ := os.exec('$vexec vget.v') or { _ := os.exec('$vexec vget.v') or {
panic(err) panic(err)
} }
//println('Done.')
} }
println('Installing module ${mod}...')
_ := os.exec('$vget $mod') or { _ := os.exec('$vget ' + names.join(' ')) or {
panic(err) panic(err)
} }
return return

View File

@ -19,14 +19,8 @@ struct Mod {
} }
fn main() { fn main() {
if os.args.len != 2 { if os.args.len <= 1 {
println('usage: vget [module]') println('usage: vget module [module] [module] [...]')
return
}
name := os.args.last()
s := http.get_text(url + '/jsmod/$name')
mod := json.decode(Mod, s) or {
println('Error. Make sure you are online.')
return return
} }
home := os.home_dir() home := os.home_dir()
@ -39,5 +33,27 @@ fn main() {
_ := os.exec('git -C "$home/.vmodules" clone --depth=1 $mod.url ' + mod.name.replace('.', '/')) or { _ := os.exec('git -C "$home/.vmodules" clone --depth=1 $mod.url ' + mod.name.replace('.', '/')) or {
panic(err) panic(err)
} }
home := os.home_dir()
if !os.dir_exists(home + '/.vmodules') {
println('Creating $home/.vmodules/ ...')
os.chdir(home)
os.mkdir('.vmodules')
println('Done.')
}
names := os.args.slice(1, os.args.len)
for name in names {
s := http.get_text(url + '/jsmod/$name')
mod := json.decode(Mod, s) or {
println('Error. Make sure you are online.')
return
}
println('Installing module $name...')
_ := os.exec('git -C $home/.vmodules clone --depth=1 $mod.url ' + mod.name.replace('.', '/')) or {
panic(err)
}
println(s) println(s)
}
} }