implement optional variable argument/option ranges, refactor exception handling
adapt required/optional argument handling implement bounded/unbounded variable argument handling
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package com.infendro.cli.exception.run
|
||||
|
||||
import com.infendro.cli.command.Option
|
||||
|
||||
class InvalidOptionCount(
|
||||
val option: Option<*>,
|
||||
val count: Int,
|
||||
) : RunException() {
|
||||
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"""
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user