Replies: 2 comments 10 replies
-
@epage should I open an issue for this? or a pull request? is there more information I can provide to make this easier to triage? |
Beta Was this translation helpful? Give feedback.
-
As I focus on use cases, we first need to break down
So I take it what you are doing is that you check for the Cargo had a similar need for arguments and we created However, not everything needs to live in clap. What you could do is mark
Overall, the context is mostly centered on rendering, rather than programmatic use. For us to do so, we'd need to provide at least every piece of context in terms of full command name path and the argument or group ID. That is a major shift and I'm not entirely sure I want clap errors to be taking on the responsibility to track all of that, especially if there are other reasonable ways of resolving the use cases. |
Beta Was this translation helpful? Give feedback.
-
Hi!
I'm not sure if I'm holding it wrong, or what — so I'm starting here.
Over in astral-sh/uv#8313 you can see we have a bad recommendation:
We should recommend
uv python uninstall
.This is our fault; it's from some error handling we added a while back, I think intending to suggest
uv pip uninstall
foruv remove
. However, now we have a bunch of other command namespaces. I took a look at trying to fix this in astral-sh/uv#8316 but I don't see a way to retrieve theCommand
at which theInvalidSubcommand
error occurred. For quick reference, it looks like the context attached to the error is:You can tell Clap has context on the current command from the
Usage
, but that's not really usable for logic. If I had access to the command, I could improve the suggestion.If there's not some way to do this, I think this will require a change to
clap
. The idea is probably to do something like 9696146 (we can either store theCommand
or just theCommand.name
) in the context (asPriorCommand
orCommand
) which would allow errors to be customized based on where in the CLI the failure occurred.Beta Was this translation helpful? Give feedback.
All reactions