Repository navigation
clap exit code - #3457
Merged
Merged
clap exit code#3457
clap exit code#3457Conversation
tertsdiepraam
force-pushed
the
clap-exit-code
branch
from
May 1, 2022 09:55
324c7fc to
ea8463f
Compare
Collaborator
Author
|
This PR now supersedes #3391 |
Contributor
|
Looks great, thanks :) |
Collaborator
Author
|
Oh I just realized a drawback to this approach. It's very hard to create colored clap errors for this and it also always prefixes the error with the util name (sorry for using images, it is necessary to show the difference with the colors): Maybe even more significantly, the help page is also rendered without colors. |
Contributor
|
Oh, sad regression :/ |
tertsdiepraam
force-pushed
the
clap-exit-code
branch
from
May 1, 2022 18:52
27bf850 to
bd85c62
Compare
Collaborator
Author
|
OK, I think I fixed it with a bit of an ugly workaround. Instead of doing what the |
tertsdiepraam
force-pushed
the
clap-exit-code
branch
2 times, most recently
from
May 4, 2022 17:10
4218a30 to
9f143dd
Compare
This allows us to use clap errors as UResult and specify the exit code for invalid arguments per util.
tertsdiepraam
force-pushed
the
clap-exit-code
branch
from
May 4, 2022 19:32
9f143dd to
c7b7f19
Compare
tertsdiepraam
marked this pull request as ready for review
May 4, 2022 20:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Step towards fixing:
To my surprise,
clap::Errorcould already be used as aUResultdue to excellent work by @shoriminimoe, which means that the exit code cal already be set to 1 by making this change inuumain:So, I added one additional bit of functionality to customize the error code:
With this change we should be able to go through all utils and fix up all the exit codes.
There is just one thing that I'm not sure about. The
UResultimplementation ofclap::Errorcurrently uses exit code1, which is (intentionally) different from the standard clap exit code of2. I'm thinking maybe the default should be2now that we can customize the exit code, so that the case where we differ from standard clap becomes explicit. @sylvestre what do you think?Leaving this as a draft to wait for feedback and then I'll fix up the other utils.