diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-07 22:22:19 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-07 22:22:19 -0800 |
commit | 2e62950a2c11793547a58c0e9b769baa30f42697 (patch) | |
tree | 33464c7edef728506dcbfee6463360f8b5cb37e0 /core | |
parent | 883c382d58ce3aabf5bd1c09c4f6a833932e8be4 (diff) | |
download | mill-2e62950a2c11793547a58c0e9b769baa30f42697.tar.gz mill-2e62950a2c11793547a58c0e9b769baa30f42697.tar.bz2 mill-2e62950a2c11793547a58c0e9b769baa30f42697.zip |
Include consistency check in main workflow
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/scala/forge/Main.scala | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/core/src/main/scala/forge/Main.scala b/core/src/main/scala/forge/Main.scala index 3820244b..a06d7d6f 100644 --- a/core/src/main/scala/forge/Main.scala +++ b/core/src/main/scala/forge/Main.scala @@ -24,35 +24,41 @@ object Main { else{ val (obj, discovered) = result.asInstanceOf[Res.Success[(Any, Discovered[Any])]].s - val mapping = Discovered.mapping(obj)(discovered) - val workspacePath = pwd / 'out - val evaluator = new Evaluator(workspacePath, mapping) - val mainRoutes = discovered.mains.map(x => (x.path :+ x.entryPoint.name, Left(x))) - val targetRoutes = discovered.targets.map(x => x._1 -> Right(x)) - val allRoutes = (mainRoutes ++ targetRoutes).toMap[ - Seq[String], - Either[NestedEntry[Any, _], (Seq[String], Format[_], Any => Target[_])] - ] - allRoutes.get(selector) match{ - case Some(Left(nestedEntryPoint)) => - nestedEntryPoint.invoke( - obj, - ammonite.main.Scripts.groupArgs(rest.toList) - ) match{ - case error: forge.discover.Router.Result.Error => - println("Failed to evaluate main method: " + error) - case forge.discover.Router.Result.Success(target) => - println("Found target! " + target) - val evaluated = evaluator.evaluate(OSet(target)) - pprint.log(evaluated) - } - - case None => println("Unknown selector: " + selector) - case Some(Right((_, _, targetFunc))) => - val target = targetFunc(obj) - val evaluated = evaluator.evaluate(OSet(target)) - pprint.log(evaluated) + val consErrors = Discovered.consistencyCheck(obj, discovered) + pprint.log(consErrors) + if (consErrors.nonEmpty) println("Failed Discovered.consistencyCheck: " + consErrors) + else { + val mapping = Discovered.mapping(obj)(discovered) + val workspacePath = pwd / 'out + val evaluator = new Evaluator(workspacePath, mapping) + val mainRoutes = discovered.mains.map(x => (x.path :+ x.entryPoint.name, Left(x))) + val targetRoutes = discovered.targets.map(x => x._1 -> Right(x)) + val allRoutes = (mainRoutes ++ targetRoutes).toMap[ + Seq[String], + Either[NestedEntry[Any, _], (Seq[String], Format[_], Any => Target[_])] + ] + allRoutes.get(selector) match{ + case Some(Left(nestedEntryPoint)) => + nestedEntryPoint.invoke( + obj, + ammonite.main.Scripts.groupArgs(rest.toList) + ) match{ + case error: forge.discover.Router.Result.Error => + println("Failed to evaluate main method: " + error) + case forge.discover.Router.Result.Success(target) => + println("Found target! " + target) + val evaluated = evaluator.evaluate(OSet(target)) + pprint.log(evaluated) + } + + case None => println("Unknown selector: " + selector) + case Some(Right((_, _, targetFunc))) => + val target = targetFunc(obj) + val evaluated = evaluator.evaluate(OSet(target)) + pprint.log(evaluated) + } } + } } } |