New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to clap 4 and improve subcommand typo error messages. #5388
Comments
I'd like to work on this. |
Assigned to @dlsmith ! |
I've opened a draft PR for the clap 4 upgrade here. |
I have a draft PR here for a change to
One related question I have is whether args should even be allowed for
|
@bhansconnect, any thoughts? |
Sorry I missed this.
Not sure how hard that would be to support, but I think it is a pretty intuitive set of functionality if it is possible to match with clap. That said, totally fine to just require the For the subcommand. I think long term the name matching would be nice (I know we already do this in the compiler for record field names, I wonder if we could just hook into that logic), but I think just adding that to the error message is also enough to clarify. 100% for requiring the command up front. |
Thanks for the suggestion to look into record field handling for matching logic. I added it to the subcommand message. It seemed simple enough to not be worth factoring out and sharing. For But I believe the current behavior should match the examples you gave, with the exception of the last. There is however a potentially confusing inconsistency, depending on whether
I don't know of a way to get around this inconsistency with |
@rtfeldman, any thoughts here? Specifically on I see it as 3 core options (not 100% sure the feasibility of each):
To my understanding, EDIT: I don't think 3 works in general. Is |
Yeah, I think this is what what we should do - that is, it's either In fact, I'd go as far as to special-case that to make scripts run even faster, e.g. match std::env::args().first() {
Some(arg) if arg.ends_with(".roc") => {
// don't even invoke clap, just immediately do a script build
}
_ => {
// do clap stuff
}
} The reason I think this is what we should do is that:
|
I think we should at least give warnings if someone passes other args to On top of that, you can send args to env: |
hmm interesting, maybe this restriction doesn't hold anymore? I asked chatGPT and it said:
Also apparently POSIX requires supporting args being passed through, so if a particular |
Okay, I think there is a big enough design question here that it shouldn't block the upgrade to clap 4. I think we should:
|
Clap 4 is already landed. This is just the arg update now. |
I guess for, we can keep all the args the same and just add the better error message for |
Totally thought this was the PR and didn't realize it was an issue. 😆 |
Thanks for weighing in, @bhansconnect and @rtfeldman! @bhansconnect, #5425 is ready for review. |
context: https://roc.zulipchat.com/#narrow/stream/231634-beginners/topic/CLI.20Error.20Message/near/356548857
Essentially, as a prereq for better error messages when a user mistypes a subcommand name, we need to first upgrade to clap 4. That will fix a bug in parsing related to requiring
--
. Currently when you mistype a subcommand name, parsing of the args fails. This means, we don't get any chance to give a better error message.So:
--
The text was updated successfully, but these errors were encountered: