19 lines
590 B
Kotlin
19 lines
590 B
Kotlin
package com.infendro.cli.exception.run
|
|
|
|
import com.infendro.cli.command.option.Option
|
|
|
|
class InvalidOptionCount(
|
|
val option: Option<*>,
|
|
val count: Int,
|
|
) : RuntimeError() {
|
|
override val message: String
|
|
get() {
|
|
val expected = when {
|
|
option.min == option.max -> "${option.min}"
|
|
option.unbounded -> "at least ${option.min}"
|
|
else -> "${option.min} to ${option.max}"
|
|
}
|
|
return """invalid number of values passed for option "${option.name}": expected $expected but found $count"""
|
|
}
|
|
}
|