diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-30 21:21:05 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-30 21:21:05 -0400 |
commit | 8a4578311e4d11c06bfb4fe04e5bf414b94d24e8 (patch) | |
tree | 249122a1a85ca0e86001fb6cc51e8278cf9fe2a3 /stage2 | |
parent | 8abb5c3ca85abc4d206afe39a2c4a98bc17560ba (diff) | |
download | cbt-8a4578311e4d11c06bfb4fe04e5bf414b94d24e8.tar.gz cbt-8a4578311e4d11c06bfb4fe04e5bf414b94d24e8.tar.bz2 cbt-8a4578311e4d11c06bfb4fe04e5bf414b94d24e8.zip |
Typed passing of values from Stage1 to Stage2
(thing can still be cleaned up)
Diffstat (limited to 'stage2')
-rw-r--r-- | stage2/AdminStage2.scala | 11 | ||||
-rw-r--r-- | stage2/AdminTasks.scala | 2 | ||||
-rw-r--r-- | stage2/Stage2.scala | 26 |
3 files changed, 18 insertions, 21 deletions
diff --git a/stage2/AdminStage2.scala b/stage2/AdminStage2.scala index cd35cfe..883b5ed 100644 --- a/stage2/AdminStage2.scala +++ b/stage2/AdminStage2.scala @@ -1,11 +1,10 @@ package cbt import java.io._ -object AdminStage2{ - def main(_args: Array[String]) = { - val args = _args.drop(1).dropWhile(Seq("admin","direct") contains _) - val init = new Init(args) - val lib = new Lib(init.logger) - val adminTasks = new AdminTasks(lib, args, new File(_args(0))) +object AdminStage2 extends Stage2Base{ + def run( _args: Stage2Args ): Unit = { + val args = _args.args.dropWhile(Seq("admin","direct") contains _) + val lib = new Lib(_args.logger) + val adminTasks = new AdminTasks(lib, args, _args.cwd) new lib.ReflectObject(adminTasks){ def usage: String = "Available methods: " ++ lib.taskNames(adminTasks.getClass).mkString(" ") }.callNullary(args.lift(0)) diff --git a/stage2/AdminTasks.scala b/stage2/AdminTasks.scala index eb1cd1e..069b712 100644 --- a/stage2/AdminTasks.scala +++ b/stage2/AdminTasks.scala @@ -2,7 +2,7 @@ package cbt import scala.collection.immutable.Seq import java.io.{Console=>_,_} import java.nio.file._ -class AdminTasks(lib: Lib, args: Array[String], cwd: File){ +class AdminTasks(lib: Lib, args: Seq[String], cwd: File){ implicit val logger: Logger = lib.logger def resolve = { ClassPath.flatten( diff --git a/stage2/Stage2.scala b/stage2/Stage2.scala index 75be3c7..e893a06 100644 --- a/stage2/Stage2.scala +++ b/stage2/Stage2.scala @@ -8,26 +8,24 @@ import scala.collection.immutable.Seq import cbt.paths._ +object Stage2 extends Stage2Base{ + def run( args: Stage2Args ): Unit = { + import args.logger -object Stage2{ - def main(args: Array[String]): Unit = { - val init = new Init(args) - import init._ + val lib = new Lib(args.logger) - val lib = new Lib(init.logger) - - init.logger.stage2(s"[$now] Stage2 start") - val loop = argsV.lift(1) == Some("loop") - val direct = argsV.lift(1) == Some("direct") + logger.stage2(s"[$now] Stage2 start") + val loop = args.args.lift(0) == Some("loop") + val direct = args.args.lift(0) == Some("direct") val taskIndex = if (loop || direct) { - 2 - } else { 1 + } else { + 0 } - val task = argsV.lift( taskIndex ) + val task = args.args.lift( taskIndex ) - val context = Context( new File(argsV(0)), argsV.drop( taskIndex + 1 ), logger, new ClassLoaderCache(logger) ) + val context = Context( args.cwd, args.args.drop( taskIndex ), logger, /*args.cbtHasChanged,*/ new ClassLoaderCache(logger) ) val first = lib.loadRoot( context ) val build = first.finalBuild @@ -56,6 +54,6 @@ object Stage2{ new lib.ReflectBuild(build).callNullary(task) } - init.logger.stage2(s"[$now] Stage2 end") + logger.stage2(s"[$now] Stage2 end") } } |