Allow specifying the max number of iterations on the command line

This commit is contained in:
Alexandre Archambault 2015-06-20 15:02:29 +01:00
parent 8ab72e7431
commit 962ef2a4aa
1 changed files with 8 additions and 1 deletions

View File

@ -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}"