Fix interface-manager badArgument hint.

This was printing arguments as their JSON serialized representation
rather than their text presentation.
It also couldn't handle missing arguments.

We also verified that writing the protection name wrong for the commands
will give you a message saying that the protection doesn't exist,
rather than showing the help command.
This commit is contained in:
gnuxie
2024-12-14 14:49:23 +00:00
committed by Gnuxie
parent a03feadb84
commit f9e3bb2e5f
@@ -163,14 +163,12 @@ function formattedArgumentHint(error: ArgumentParseError): string {
error.partialCommand.stream.getPosition()
);
let commandContext = "Command context:";
for (const designator of error.partialCommand.designator) {
commandContext += ` ${designator}`;
}
for (const argument of argumentsUpToError) {
commandContext += ` ${JSON.stringify(argument)}`;
commandContext += ` ${TextPresentationRenderer.render(argument)}`;
}
const badArgument = ` ${TextPresentationRenderer.render(error.partialCommand.stream.peekItem())}\n${Array(commandContext.length + 1).join(" ")} ^ expected ${printPresentationSchema(error.parameter.acceptor)} here`;
return commandContext + badArgument;
const badArgument = error.partialCommand.stream.peekItem();
const badArgumentHint = ` ${badArgument === undefined ? "undefined" : TextPresentationRenderer.render(badArgument)}\n${Array(commandContext.length + 1).join(" ")} ^ expected ${printPresentationSchema(error.parameter.acceptor)} here`;
return commandContext + badArgumentHint;
}
export async function reactToEventWithResult(