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

Isolate install_v to reduce complexity

This commit is contained in:
Vitor Oliveira 2019-09-10 01:22:16 -07:00 committed by Alexander Medvednikov
parent 0ade45db08
commit cd47f09f86

View File

@ -134,34 +134,7 @@ fn main() {
return
}
if 'install' in args {
if args.len < 3 {
println('usage: v install [module] [module] [...]')
return
}
names := args.slice(2, args.len)
vexec := os.executable()
vroot := os.dir(vexec)
vget := '$vroot/tools/vget'
if true {
//println('Building vget...')
os.chdir(vroot + '/tools')
vgetcompilation := os.exec('$vexec -o $vget vget.v') or {
cerror(err)
return
}
if vgetcompilation.exit_code != 0 {
cerror( vgetcompilation.output )
return
}
}
vgetresult := os.exec('$vget ' + names.join(' ')) or {
cerror(err)
return
}
if vgetresult.exit_code != 0 {
cerror( vgetresult.output )
return
}
install_v(args)
return
}
// TODO quit if the compiler is too old
@ -931,6 +904,37 @@ fn update_v() {
}
}
fn install_v(args[]string) {
if args.len < 3 {
println('usage: v install [module] [module] [...]')
return
}
names := args.slice(2, args.len)
vexec := os.executable()
vroot := os.dir(vexec)
vget := '$vroot/tools/vget'
if true {
//println('Building vget...')
os.chdir(vroot + '/tools')
vgetcompilation := os.exec('$vexec -o $vget vget.v') or {
cerror(err)
return
}
if vgetcompilation.exit_code != 0 {
cerror( vgetcompilation.output )
return
}
}
vgetresult := os.exec('$vget ' + names.join(' ')) or {
cerror(err)
return
}
if vgetresult.exit_code != 0 {
cerror( vgetresult.output )
return
}
}
fn test_v() {
args := env_vflags_and_os_args()
vexe := args[0]