Skip to content

Add a Stdin Specification#586

Open
jfly wants to merge 2 commits intonumtide:mainfrom
jfly:issue-573-stdin-spec
Open

Add a Stdin Specification#586
jfly wants to merge 2 commits intonumtide:mainfrom
jfly:issue-573-stdin-spec

Conversation

@jfly
Copy link
Collaborator

@jfly jfly commented May 13, 2025

This described the Stdin Specification, and adds a new formatter.stdin_options config to enable treefmt to invoke formatters in "stdin mode".

@jfly
Copy link
Collaborator Author

jfly commented Jun 24, 2025

@brianmcgee @zimbatm, is there anything I can do to help move this forward?

@brianmcgee
Copy link
Member

It's unclear to me if this documents the current behaviour or the desired behaviour. If it's the desired behaviour, isn't there some work needing to be done in treefmt to support that before we publish a spec?

@jfly jfly marked this pull request as draft June 28, 2025 15:00
@jfly
Copy link
Collaborator Author

jfly commented Jun 28, 2025

If it's the desired behaviour, isn't there some work needing to be done in treefmt to support that before we publish a spec?

Yes, treefmt needs changes to support this. I'm happy to implement that (in this PR or a separate one). I just don't want to put in the effort until I know we like this approach.

@brianmcgee
Copy link
Member

I'll try to put my brain on this in the next few days. Been a busy few weeks 😫

@jfly
Copy link
Collaborator Author

jfly commented Jul 21, 2025

@brianmcgee, friendly ping

Copy link
Member

@brianmcgee brianmcgee left a comment

Choose a reason for hiding this comment

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

I agree with some of your own musings in the comments you'd left. Otherwise, it seems like a sane spec and one which should be easy enough for formatters to follow.

I also like that this is opt-in.

@brianmcgee
Copy link
Member

P.S. Thanks for taking the time to flesh this out, and sorry for taking a while to get around to reviewing this.

@jfly jfly force-pushed the issue-573-stdin-spec branch 4 times, most recently from 8e6e1cb to 5671029 Compare July 21, 2025 22:25
@jfly jfly force-pushed the issue-573-stdin-spec branch from 5671029 to d8276a6 Compare July 22, 2025 20:02
@jfly jfly requested a review from brianmcgee July 22, 2025 20:09
Copy link
Contributor

@infinisil infinisil left a comment

Choose a reason for hiding this comment

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

LGTM!

@jfly
Copy link
Collaborator Author

jfly commented Jul 22, 2025

@brianmcgee @zimbatm, I could use another review on this. If we're happy with the state of this, then I'd like to work on the underlying implementation.

Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

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

Some minor things, but directionally it makes sense.

formatting "virtual files" passed via stdin.

A formatter **MUST** implement the Stdin Specification if its formatting behavior
can depend on the name of the file being formatted.
Copy link
Member

Choose a reason for hiding this comment

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

this is a bit hard to read

Copy link
Collaborator Author

@jfly jfly Aug 10, 2025

Choose a reason for hiding this comment

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

I agree, but I don't know how to fix it. Does flipping the sentence around help? Suggestions appreciated.

If a formatter's behavior can depend on the name of the file being formatted, then it MUST implement the Stdin Specification.

@cstrahan
Copy link

Any remaining work to be done here, or is this just waiting for review?

I'd be happy to lend a hand, if there's any way I can help.

@jfly
Copy link
Collaborator Author

jfly commented Oct 27, 2025

@cstrahan I think this is ready for implementation. I'm pretty swamped right now. If you're up for putting together an implementation, I'd be happy to code review!

@jfly jfly force-pushed the issue-573-stdin-spec branch 4 times, most recently from 9def6de to 21002ef Compare March 7, 2026 08:40
@jfly jfly force-pushed the issue-573-stdin-spec branch from 21002ef to 9995441 Compare March 7, 2026 08:42
@jfly jfly marked this pull request as ready for review March 7, 2026 08:43
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.

6 participants