rename RunError to RuntimeFailure
This commit is contained in:
@@ -19,13 +19,13 @@ internal class ContextParser(
|
||||
|
||||
data class Failure(
|
||||
val path: List<Command>,
|
||||
val error: RunError,
|
||||
val failure: RuntimeFailure,
|
||||
) : Result()
|
||||
}
|
||||
|
||||
private fun success(context: Context) = Result.Success(context)
|
||||
private fun help(path: List<Command>) = Result.Help(path)
|
||||
private fun failure(path: List<Command>, exception: RunError) = Result.Failure(path, exception)
|
||||
private fun failure(path: List<Command>, exception: RuntimeFailure) = Result.Failure(path, exception)
|
||||
|
||||
private var index = 0
|
||||
private val current: String
|
||||
@@ -63,7 +63,7 @@ internal class ContextParser(
|
||||
if (cmd is Command.Fallback<*>) {
|
||||
val value = when (val result = cmd.parser.parse(current)) {
|
||||
is Parser.Result.Success<*> -> result.value
|
||||
is Parser.Result.Failure<*> -> return failure(path, result.error)
|
||||
is Parser.Result.Failure<*> -> return failure(path, result.failure)
|
||||
}
|
||||
commands[cmd.key] = value
|
||||
}
|
||||
@@ -91,7 +91,7 @@ internal class ContextParser(
|
||||
|
||||
val value = when (val result = argument.parser.parse(trimmed)) {
|
||||
is Parser.Result.Success<*> -> result.value
|
||||
is Parser.Result.Failure<*> -> return failure(path, result.error)
|
||||
is Parser.Result.Failure<*> -> return failure(path, result.failure)
|
||||
}
|
||||
arguments[argument]!! += value
|
||||
argumentCount++
|
||||
@@ -141,7 +141,7 @@ internal class ContextParser(
|
||||
text != null ->
|
||||
when (val result = option.parser.parse(current)) {
|
||||
is Parser.Result.Success<*> -> result.value
|
||||
is Parser.Result.Failure<*> -> return failure(path, result.error)
|
||||
is Parser.Result.Failure<*> -> return failure(path, result.failure)
|
||||
}
|
||||
option.flag -> option.fallback!!
|
||||
else -> return failure(path, MissingOptionValue(option))
|
||||
|
||||
Reference in New Issue
Block a user