Expose source spans for errors with error-context #4948
Labels
A-parsing
Area: Parser's logic and needs it changed somehow.
C-enhancement
Category: Raise on the bar on expectations
S-waiting-on-design
Status: Waiting on user-facing design to be resolved before implementing
Please complete the following tasks
Clap Version
master
Describe your use case
I'm building a compiler front-end and I want to use a common diagnostic format for all of the errors, whether in the input source code with linting or parsing or analysis, and I want this to extend also to the cli arguments. For some kinds of clap errors, such as InvalidValue, it would be nice to show the context around the argument based on the command that the user typed. As far as I can tell, clap does not currently support this use case.
I could write my own parser for the command line, but it would be nice to reuse the work that clap has done, even with my own error display logic.
Describe the solution you'd like
Clap already has a crate feature called
error-context
that supports most of what I need. I propose adding a new context kind that supplies some sort of source span for errors where that is relevant.Alternatives, if applicable
No response
Additional Context
I have used clap for many years and love the work you've done. I would be happy to contribute by writing a PR for this feature of the maintainers would be willing to accept it.
The text was updated successfully, but these errors were encountered: