implement suggestions for unknown command/option
This commit is contained in:
@@ -53,7 +53,7 @@ internal class ContextParser(
|
||||
}
|
||||
if (cmd == null) {
|
||||
when {
|
||||
command.arguments.isEmpty() -> return failure(path, UnknownCommand(current))
|
||||
command.arguments.isEmpty() -> return failure(path, UnknownCommand(command, current))
|
||||
else -> break
|
||||
}
|
||||
}
|
||||
@@ -87,9 +87,9 @@ internal class ContextParser(
|
||||
// argument
|
||||
endOfOptions || dashes == 0 -> {
|
||||
val argument = command.arguments.getOrNull(argumentIndex)
|
||||
?: return failure(path, UnexpectedArgument())
|
||||
?: return failure(path, UnexpectedArgument(current))
|
||||
|
||||
val value = when (val result = argument.parser.parse(trimmed)) {
|
||||
val value = when (val result = argument.parser.parse(current)) {
|
||||
is Parser.Result.Success<*> -> result.value
|
||||
is Parser.Result.Failure<*> -> return failure(path, result.failure)
|
||||
}
|
||||
@@ -135,7 +135,7 @@ internal class ContextParser(
|
||||
|
||||
for (name in names) {
|
||||
val option = command.options.firstOrNull { name in it.names }
|
||||
?: return failure(path, UnknownOption(name))
|
||||
?: return failure(path, UnknownOption(command, name))
|
||||
|
||||
val value = when {
|
||||
text != null ->
|
||||
|
||||
Reference in New Issue
Block a user