From 962ef2a4aaf95a6fa0359799a5cbcfd397b18138 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Sat, 20 Jun 2015 15:02:29 +0100 Subject: [PATCH] Allow specifying the max number of iterations on the command line --- cli/src/main/scala/coursier/cli/Coursier.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cli/src/main/scala/coursier/cli/Coursier.scala b/cli/src/main/scala/coursier/cli/Coursier.scala index 2e14c1926..118650904 100644 --- a/cli/src/main/scala/coursier/cli/Coursier.scala +++ b/cli/src/main/scala/coursier/cli/Coursier.scala @@ -12,7 +12,8 @@ import scalaz.{-\/, \/-} case class Coursier(scope: List[String], keepOptional: Boolean, - fetch: Boolean) extends App { + fetch: Boolean, + @ExtraName("N") maxIterations: Int) extends App { val scopes0 = if (scope.isEmpty) List(Scope.Compile, Scope.Runtime) @@ -85,9 +86,15 @@ case class Coursier(scope: List[String], val res = resolve( deps.toSet, fetchFrom(repositories), + maxIterations = Some(maxIterations).filter(_ > 0), filter = Some(dep => (keepOptional || !dep.optional) && scopes(dep.scope)) ).run + if (!res.isDone) { + println(s"Maximum number of iteration reached!") + sys exit 1 + } + def repr(dep: Dependency) = s"${dep.module.organization}:${dep.module.name}:${dep.`type`}:${Some(dep.classifier).filter(_.nonEmpty).map(_+":").mkString}${dep.version}"