You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.2 KiB
Kotlin
31 lines
1.2 KiB
Kotlin
3 years ago
|
package io.provs
|
||
|
|
||
|
|
||
|
data class ProvResult(val success: Boolean,
|
||
|
val cmd: String? = null,
|
||
|
val out: String? = null,
|
||
|
val err: String? = null,
|
||
|
val exception: Exception? = null,
|
||
|
val exit: String? = null) {
|
||
|
|
||
|
constructor(returnCode : Int) : this(returnCode == 0)
|
||
|
|
||
|
override fun toString(): String {
|
||
|
return "ProvResult:: ${if (success) "Succeeded" else "FAILED"} -- ${if (!cmd.isNullOrEmpty()) "Name: " +
|
||
|
cmd.escapeNewline() + ", " else ""}${if (!out.isNullOrEmpty()) "Details: $out" else ""}" +
|
||
|
(exception?.run { " Exception: " + toString() } ?: "")
|
||
|
}
|
||
|
|
||
|
fun toShortString() : String {
|
||
|
return "ProvResult:: ${if (success) "Succeeded" else "FAILED"} -- ${if (!success && (out != null)) "Details: $out" else ""}"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
@Suppress("unused") // might be used by custom methods
|
||
|
data class TypedResult<T>(val success: Boolean, val resultObject: T? = null) {
|
||
|
override fun toString(): String {
|
||
|
return "TypedResult:: ${if (success) "Succeeded" else "FAILED"} -- Result object: " + resultObject?.run { toString().escapeNewline() }
|
||
|
}
|
||
|
}
|