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

Incorrect error when using the --output-format=summary flag #943

Open
eitamal opened this issue Jan 7, 2025 · 2 comments
Open

Incorrect error when using the --output-format=summary flag #943

eitamal opened this issue Jan 7, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@eitamal
Copy link
Contributor

eitamal commented Jan 7, 2025

I think I found a bug! 🐛
(just a small one)

When invoking StyLua with the summary output format and without the check flag, e.g.

stylua --output-format=summary file.lua

I get an error:

error: --output-format=unified and --output-format=standard can only be used when --check is enabled

which, as you might have noticed, doesn't mention summary. So, I had a look at the code to see if I was missing something, and found this:

 // Check for incompatible options
    if !opt.check
        && matches!(
            opt.output_format,
            opt::OutputFormat::Unified | opt::OutputFormat::Summary
        )
    {
        bail!("--output-format=unified and --output-format=standard can only be used when --check is enabled");
    }

So it looks like either the check is missing standard and the error message is missing summary or the check should be checking standard instead of summary. But I don't know Rust, and I'm not sure what the expected behaviour should be - so I'm not sure how/what the fix would be.

@JohnnyMorganz
Copy link
Owner

Thanks!

Took me a while to figure out what the behaviour should be 😅, but looks like my intention was that --output-format=summary can only be used when --check is enabled (5840654).

So, I think the check is correct, but the error message is wrong. The error message should say --output-format=summary.

@eitamal
Copy link
Contributor Author

eitamal commented Jan 13, 2025

Ah that makes perfect sense - thanks for clarifying! Now that you mention it, having to use --check with the default output format (i.e. standard) doesn't seem quite right.

Anyway, I've made the PR (#949) if you want it and thank you for the quick response and for maintaining this awesome project! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants