-
Notifications
You must be signed in to change notification settings - Fork 893
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
cli: exit gracefully when no subcommand #2427
cli: exit gracefully when no subcommand #2427
Conversation
As noted here: #2425 (comment) I think that we might want to investigate why |
I think |
So there's consistency in how it responds with these features. |
Yes, but it would, by default, report these on stderr and exit with failure: https://github.com/clap-rs/clap/blob/v2-master/src/errors.rs#L385 |
Interesting, that might be a separate issue though. I don't know. It's worth noting that It does seem quite confusing. |
You've found a difference in behaviour between 1.21 and 1.22 (the presence of |
Fantastic, let's wait and see what the clap people say about the behaviour. |
@kinnison According to clap-rs/clap#2021 (comment) this would be a breaking change if changed and so if it is changed that will be limited to v3. |
Looks like I have some tests to fix, I'll get on that. |
Cool, making sure that over all our behaviour is clean is the goal. You may also want to rebase as I merged another test improvement from Robert earlier today. |
I prefer rebases over merges, it makes for a clearer commit sequence to review. However I can wait for now and we can clean this up later. Are you sure that the changes in behaviour that your test changes imply are desired? Are older rustup behaviours now being changed? I ask because if we've broken how rustup used to behave then we need to be careful if anything might be used in scripting or similar. |
I force pushed a squash of the commits rebased on master to make the history clean.
We could keep the error code return without the What do you recommend? |
Sorry it took me so long to get back here. Thank you for the squash, that makes it easier to read the commit. As for behaviour, I personally would prefer that whatever the behaviour was in versions before we started this refactor (so 1.21 or earlier) were preserved for anything where scripting might be used to detect errors. If it's purely in interactive behaviours then it's probably fine to change behaviour, though if the help text goes to stderr then it is opportunistic help and should have an exit code which reflects that (i.e. non-zero in some form). I don't mind losing the |
@kinnison @rbtcollins The PR is updated to maintain the existing exit code when executed without subcommands, while losing the |
Could you please rebase this to reflect the final changes being done, rather than the review-edit-cycle? Thanks! |
@rbtcollins The PR is updated with a force-push that squashes the commits into a single commit. The diff and the change are identical. |
What
Exit from rustup CLI gracefully when no subcommand is provided.
Why
That appears to be the intention because the
SubcommandRequiredElseHelp
app setting is configured on the CLI, however that is not the behavior because themain
function treats the error indicating no subcommand was provided as an error.rustup/src/cli/rustup_mode.rs
Lines 152 to 159 in 22dc71a
Instead of exiting gracefully the word
error:
is printed with no error message:Fixes #2425
Known Limitations
I have not added tests for this change. I'm rather new to rust and this codebase and I could not find tests for this code to modify or change.