swift-argument-parser
swift-argument-parser copied to clipboard
Incorrect flag in error message
In the following example, the caller has substituted a single dash for a double in the sound key/value pair:
% remind -d 20 my reminder -sound tink
Error: The value 'tink' is invalid for '-d <days>'
The error should read:
Error: The value 'tink' is invalid for '-s <seconds>'
Thanks for the bug report, @erica! Could you show the command declaration for this? I can’t quite get this error to reproduce.
Turns out that I've removed -s for seconds, so -s does not match a valid command. But -sound matches the long option --sound. I think the error message should be easy to construct as "used the wrong hyphenation" here
Ah, that makes more sense! What’s happening is that the parser is first looking to see if something matches -sound, not finding it, and then checking to see if sound is a pack of short options. It finds -d at the end, but tink is an invalid value.
To fix this, we’ll need to decide whether we should do near-miss matching when we partially match (or error while partially matching) on a single-dashed argument.
In the following example, the caller has substituted a single dash for a double in the
soundkey/value pair:% remind -d 20 my reminder -sound tink Error: The value 'tink' is invalid for '-d <days>'The error should read:
Error: The value 'tink' is invalid for '-s <seconds>'
Sorry to bother but is it possible for you to point to the code you're talking about (ie: the part of the code printing the error, and the part where the flag is defined), please?
I'm going through the issues to try and help but I don't know what to do about this one. I'll just move on.
Cheers, — AJ