mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v install: install multiple modules in one command: 'v install m1 m2 m3 …'
This commit is contained in:
parent
a0b583d8c8
commit
c67783bcd1
@ -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,13 +141,12 @@ 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
|
||||||
}
|
}
|
||||||
// TODO quit if the compiler is too old
|
// TODO quit if the compiler is too old
|
||||||
// u := os.file_last_mod_unix('v')
|
// u := os.file_last_mod_unix('v')
|
||||||
|
36
tools/vget.v
36
tools/vget.v
@ -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)
|
||||||
}
|
}
|
||||||
println(s)
|
|
||||||
}
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user