diff --git a/compiler/main.v b/compiler/main.v index 6ea8993fb1..a43f839115 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -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]