Skip to content

Conversation

@mkatychev
Copy link
Member

@mkatychev mkatychev commented Sep 25, 2025

Add topiary check-grammar subcommand

References #977

Description

The topiary check-grammar (with topiary check alias) subcommand
checks that one or more inputs are parseable to a tree-sitter grammar,
returning all locations where a parsing error occurred:

image

Checklist

Checklist before merging, wherever relevant:

  • CHANGELOG.md updated
  • Documentation (The Topiary Book, README.md, etc.) up-to-date
  • Updated regression tests

@mkatychev mkatychev changed the title feat(cli): add topiary check command feat(cli): Add topiary check command Sep 26, 2025
@mkatychev mkatychev changed the title feat(cli): Add topiary check command feat(cli): Add topiary check-grammar subcommand Sep 26, 2025
@mkatychev mkatychev marked this pull request as ready for review September 26, 2025 19:26
Copy link
Member

@Xophmeister Xophmeister left a comment

Choose a reason for hiding this comment

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

As always, this looks great, @mkatychev 🙏

I've left a few very minor suggestions, but this is good to go.

match self {
Self::Stdin => write!(f, "standard input"),
Self::Disk(path, _) => write!(f, "{}", path.to_string_lossy()),
Self::Disk(path, _) => write!(f, "{}", path.display()),
Copy link
Member

Choose a reason for hiding this comment

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

TIL That path.display() will do the lossy UTF-8 conversion... but if PathBuf implements Display, then surely one can write write!(f, "{path}")?

Copy link
Member Author

Choose a reason for hiding this comment

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

https://doc.rust-lang.org/std/path/struct.PathBuf.html#impl-Debug-for-PathBuf I don't think it implements display, LMK if you see it though!

Copy link
Member

Choose a reason for hiding this comment

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

No, you're right: It's because of there's a Deref<Target=Path> implementation, which is where the .display comes from 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

I've moved most of the logging over to path.display()

// meant to be used in scenarios where multiple inputs are possible
pub(crate) async fn process_inputs<F>(inputs: Inputs<'_>, process_fn: F) -> CLIResult<()>
where
F: Fn(InputFile, Arc<Language>) -> CLIResult<()> + Send + Sync + 'static,
Copy link
Member

Choose a reason for hiding this comment

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

Nice 👍

@mkatychev mkatychev merged commit 2ba1b98 into tweag:main Sep 29, 2025
11 checks passed
@mkatychev mkatychev deleted the feat/check-command branch September 29, 2025 21:00
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.

2 participants