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

feat: rewrite the format function #86

Merged
merged 1 commit into from
Jul 14, 2024

Conversation

jaudiger
Copy link
Contributor

Resolve #85

Add the formatted files and better handle errors happened on a project when formatting more than once at the same time as suggested by @kylewlacy #84 (review)

…etter handle errors happened on a project when formatting more than once at the same time

Signed-off-by: jaudiger <[email protected]>
@jaudiger
Copy link
Contributor Author

Some examples:

cargo run -- fmt --check -p ../brioche-packages/packages/bat -p ../brioche-packages/packages/biome -p ../brioche-packages/packages/go -p ../brioche-packages/packages/biom
   Compiling brioche v0.1.1 (/Users/jaudiger/Development/git-repositories/jaudiger/brioche/crates/brioche)
    Finished `dev` profile [optimized + debuginfo] target(s) in 32.03s
     Running `target/debug/brioche fmt --check -p ../brioche-packages/packages/bat -p ../brioche-packages/packages/biome -p ../brioche-packages/packages/go -p ../brioche-packages/packages/biom`
[938µs] 0 / 0 jobs complete
The following files of project '../brioche-packages/packages/bat' are not formatted:
- /Users/jaudiger/Development/git-repositories/jaudiger/brioche-packages/packages/bat/project.bri
[106.1ms] 0 / 0 jobs complete
The following files of project '../brioche-packages/packages/biome' are not formatted:
- /Users/jaudiger/Development/git-repositories/jaudiger/brioche-packages/packages/biome/project.bri
[211.2ms] 0 / 0 jobs complete
All files of project '../brioche-packages/packages/go' are formatted

Error occurred while formatting project '../brioche-packages/packages/biom': failed to canonicalize path ../brioche-packages/packages/biom
cargo run -- fmt -p ../brioche-packages/packages/bat -p ../brioche-packages/packages/biome -p ../brioche-packages/packages/go -p ../brioche-packages/packages/biom        
    Finished `dev` profile [optimized + debuginfo] target(s) in 0.78s
     Running `target/debug/brioche fmt -p ../brioche-packages/packages/bat -p ../brioche-packages/packages/biome -p ../brioche-packages/packages/go -p ../brioche-packages/packages/biom`
[947µs] 0 / 0 jobs complete
The following files of project '../brioche-packages/packages/bat' have been formatted:
- /Users/jaudiger/Development/git-repositories/jaudiger/brioche-packages/packages/bat/project.bri
[106.3ms] 0 / 0 jobs complete
The following files of project '../brioche-packages/packages/biome' have been formatted:
- /Users/jaudiger/Development/git-repositories/jaudiger/brioche-packages/packages/biome/project.bri
[211.5ms] 0 / 0 jobs complete
Error occurred while formatting project '../brioche-packages/packages/biom': failed to canonicalize path ../brioche-packages/packages/biom

@jaudiger
Copy link
Contributor Author

There is still one issue with that PR. Each last line from println!()statements seems to be eaten. I think it comes from the console reporter, but I'm unsure.

Copy link
Member

@kylewlacy kylewlacy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kylewlacy
Copy link
Member

There is still one issue with that PR. Each last line from println!()statements seems to be eaten. I think it comes from the console reporter, but I'm unsure.

Yeah, that sounds like another issue I've seen related to the formatter where the last line of the console output gets overridden... I think the issue is that superconsole doesn't mix well with println!, and so doing everything through the reporter would be better

@kylewlacy kylewlacy merged commit e80c0e1 into brioche-dev:main Jul 14, 2024
5 checks passed
@jaudiger jaudiger deleted the format-rewrite branch July 14, 2024 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CLI] Print files that were just formatted
2 participants