mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Don’t display progress if no terminal is available.
This commit is contained in:
parent
4d04cddc6e
commit
fecf4324dd
1 changed files with 6 additions and 1 deletions
|
@ -30,7 +30,12 @@ class ConsoleTransferListener @JvmOverloads constructor(out: PrintStream? = null
|
||||||
kobaltLog(2, message + ": " + event.resource.repositoryUrl + event.resource.resourceName)
|
kobaltLog(2, message + ": " + event.resource.repositoryUrl + event.resource.resourceName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val PROPERTY_NO_ANIMATIONS = "com.beust.kobalt.noAnimations"
|
||||||
|
|
||||||
override fun transferProgressed(event: TransferEvent?) {
|
override fun transferProgressed(event: TransferEvent?) {
|
||||||
|
// Not on a terminal: don't display the progress
|
||||||
|
if (System.console() == null || System.getProperty(PROPERTY_NO_ANIMATIONS) != null) return
|
||||||
|
|
||||||
val resource = event!!.resource
|
val resource = event!!.resource
|
||||||
downloads.put(resource, java.lang.Long.valueOf(event.transferredBytes))
|
downloads.put(resource, java.lang.Long.valueOf(event.transferredBytes))
|
||||||
|
|
||||||
|
@ -120,7 +125,7 @@ class ConsoleTransferListener @JvmOverloads constructor(out: PrintStream? = null
|
||||||
Exceptions.printStackTrace(event!!.exception)
|
Exceptions.printStackTrace(event!!.exception)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun toKB(bytes: Long): Long {
|
fun toKB(bytes: Long): Long {
|
||||||
return (bytes + 1023) / 1024
|
return (bytes + 1023) / 1024
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue