Skip to content
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

Support pretty diagnostic messages in CLI #495

Open
JohnnyMorganz opened this issue Nov 18, 2023 · 6 comments · May be fixed by #908
Open

Support pretty diagnostic messages in CLI #495

JohnnyMorganz opened this issue Nov 18, 2023 · 6 comments · May be fixed by #908
Labels
enhancement New feature or request good first issue Good for newcomers pr welcome We would support a contribution for this change

Comments

@JohnnyMorganz
Copy link
Owner

Would be nice to be able to report something in a similar fashion to Rust's https://github.com/brendanzab/codespan in the analyze tool

There is https://github.com/Excse/pretty_diagnostics already that is somewhat similar. Or maybe it doesn't take too much effort to port the codespan library

@JohnnyMorganz JohnnyMorganz added the enhancement New feature or request label Nov 18, 2023
@JohnnyMorganz JohnnyMorganz added pr welcome We would support a contribution for this change good first issue Good for newcomers labels Nov 10, 2024
@danaetroupe
Copy link

danaetroupe commented Jan 15, 2025

1. For the design, I'm looking at
This TS example:
image
This example from provided repository:
image
This example from alternative repository
image
Rust example:
image

Which elements do you want this feature to have?

2. Same file support
Currently the CLI does not appear to support grouped error messages for the same file. Do you want this to be supported? e.g. Providing the file name once and then grouping all relevant errors.

@JohnnyMorganz

@JohnnyMorganz
Copy link
Owner Author

Hey, thanks for taking a look at this, looking forward to seeing the end result!

At the moment the main things that would be interesting to me are the colours, original input code snapshot view, and also the general structuring of the messages. The alternative repository that you found seems quite cool. (When I was first thinking about this, I was also curious how difficult it would be to port the codespan Rust code directly)

I'm not completely sure about the same file grouping, do you have an example? I think it makes sense to me to support this though, less noisy errors are best.

Couple of other things:

  • We should make the style of output configurable so that users can fall back to the existing style if they want (it is easier to parse). In future we might also want to support JSON output (but that's out of scope for this particular change)
  • We may want an option to disable colours (useful for non interactive terminals). But this one also doesn't need to be implemented immediately and could be done in a follow up

1 similar comment
@JohnnyMorganz
Copy link
Owner Author

Hey, thanks for taking a look at this, looking forward to seeing the end result!

At the moment the main things that would be interesting to me are the colours, original input code snapshot view, and also the general structuring of the messages. The alternative repository that you found seems quite cool. (When I was first thinking about this, I was also curious how difficult it would be to port the codespan Rust code directly)

I'm not completely sure about the same file grouping, do you have an example? I think it makes sense to me to support this though, less noisy errors are best.

Couple of other things:

  • We should make the style of output configurable so that users can fall back to the existing style if they want (it is easier to parse). In future we might also want to support JSON output (but that's out of scope for this particular change)
  • We may want an option to disable colours (useful for non interactive terminals). But this one also doesn't need to be implemented immediately and could be done in a follow up

@danaetroupe
Copy link

Porting Rust code directly -> I looked into this as well and there are ways to interpolate Rust and C++ code which involves explicitly defining the functions you want to use on both the Rust and C++ side but I am hesitant to consider this as a solution as it may introduce unnecessary complexity to what should be a simple feature. Also, there has to be a separate compilation to generate a static library file that could make future changes difficult.

File Grouping -> In the VS code extension itself, errors are grouped by filename whereas in the CLI the filename may be repeated several times in each error. Outside of this feature this could also be a general improvement on the CLI formatting. (See below)
image

Configurable Output -> I agree. As of now I've extended the --formatter flag to have a "prettier" option. If there are any other ways to configure output that I'm not aware of let me know. I actually got the flag working but encountered some character display issues with one of the repositories so I'm more focused on the design aspect now. (See below)
image

@danaetroupe
Copy link

danaetroupe commented Jan 18, 2025

Output examples

Short Error
Image
Multiple Errors
Image

You can now request prettier errors from the CL using QazmoQwerty/error-reporter. The flag is --formatter prettier. Open to design changes before submitting a pull request. @JohnnyMorganz

@danaetroupe
Copy link

It's also worth mentioning that this may not be compatible with all terminals but I think it's a nonissue considering the implementation is not enabled by default.

@danaetroupe danaetroupe linked a pull request Jan 23, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers pr welcome We would support a contribution for this change
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants