Adjust default verbosity settings of CLI tool

This commit is contained in:
Alexandre Archambault 2016-03-13 22:57:26 +01:00
parent 265977cdfe
commit 60f421346f
3 changed files with 18 additions and 17 deletions

View File

@ -190,7 +190,7 @@ class Helper(
)
val logger =
if (verbose0 >= 0)
if (verbosityLevel >= 0)
Some(new TermDisplay(new OutputStreamWriter(System.err)))
else
None
@ -204,17 +204,17 @@ class Helper(
fetchs.tail: _*
)
val fetch0 =
if (verbose0 <= 0) fetchQuiet
else {
if (verbosityLevel >= 2) {
modVers: Seq[(Module, String)] =>
val print = Task {
errPrintln(s"Getting ${modVers.length} project definition(s)")
}
print.flatMap(_ => fetchQuiet(modVers))
}
} else
fetchQuiet
if (verbose0 >= 0) {
if (verbosityLevel >= 1) {
errPrintln(s" Dependencies:\n${Print.dependenciesUnknownConfigs(dependencies, Map.empty)}")
if (forceVersions.nonEmpty) {
@ -237,8 +237,9 @@ class Helper(
lazy val projCache = res.projectCache.mapValues { case (_, p) => p }
if (printResultStdout || verbose0 >= 0) {
errPrintln(s" Result:")
if (printResultStdout || verbosityLevel >= 1) {
if ((printResultStdout && verbosityLevel >= 1) || verbosityLevel >= 2)
errPrintln(s" Result:")
val depsStr = Print.dependenciesUnknownConfigs(trDeps, projCache)
if (printResultStdout)
println(depsStr)
@ -285,7 +286,7 @@ class Helper(
subset: Set[Dependency] = null
): Seq[Artifact] = {
if (subset == null && verbose0 >= 0) {
if (subset == null && verbosityLevel >= 1) {
val msg = cachePolicies match {
case Seq(CachePolicy.LocalOnly) =>
" Checking artifacts"
@ -319,12 +320,12 @@ class Helper(
val artifacts0 = artifacts(sources, javadoc, subset)
val logger =
if (verbose0 >= 0)
if (verbosityLevel >= 0)
Some(new TermDisplay(new OutputStreamWriter(System.err)))
else
None
if (verbose0 >= 1 && artifacts0.nonEmpty)
if (verbosityLevel >= 1 && artifacts0.nonEmpty)
println(s" Found ${artifacts0.length} artifacts")
val tasks = artifacts0.map(artifact =>

View File

@ -80,9 +80,9 @@ case class Launch(
Launch.mainClassLoader(contextLoader)
.flatMap(cl => Option(cl.getParent))
.getOrElse {
if (options.common.verbose0 >= 0)
if (options.common.verbosityLevel >= 0)
Console.err.println(
"Warning: cannot find the main ClassLoader that launched coursier. " +
"Warning: cannot find the main ClassLoader that launched coursier.\n" +
"Was coursier launched by its main launcher? " +
"The ClassLoader of the application that is about to be launched will be intertwined " +
"with the one of coursier, which may be a problem if their dependencies conflict."
@ -107,7 +107,7 @@ case class Launch(
subset = options.isolated.isolatedDeps.getOrElse(target, Seq.empty).toSet
)
if (options.common.verbose0 >= 1) {
if (options.common.verbosityLevel >= 2) {
Console.err.println(s"Isolated loader files:")
for (f <- isolatedFiles.map(_.toString).sorted)
Console.err.println(s" $f")
@ -124,7 +124,7 @@ case class Launch(
(isolatedLoader, filteredFiles0)
}
if (options.common.verbose0 >= 1) {
if (options.common.verbosityLevel >= 2) {
Console.err.println(s"Remaining files:")
for (f <- filteredFiles0.map(_.toString).sorted)
Console.err.println(s" $f")
@ -186,9 +186,9 @@ case class Launch(
sys.exit(255)
}
if (options.common.verbose0 >= 1)
if (options.common.verbosityLevel >= 2)
Helper.errPrintln(s"Launching $mainClass0 ${extraArgs.mkString(" ")}")
else if (options.common.verbose0 == 0)
else if (options.common.verbosityLevel == 1)
Helper.errPrintln(s"Launching")
Thread.currentThread().setContextClassLoader(loader)

View File

@ -57,7 +57,7 @@ case class CommonOptions(
@Recurse
cacheOptions: CacheOptions
) {
val verbose0 = Tag.unwrap(verbose) - (if (quiet) 1 else 0)
val verbosityLevel = Tag.unwrap(verbose) - (if (quiet) 1 else 0)
lazy val classifier0 = classifier.flatMap(_.split(',')).filter(_.nonEmpty)
}