feat: zero fmt --write and --check --json envelope#46
Open
gke0op wants to merge 1 commit into
Open
Conversation
Adds --write flag and --json envelope support to zero fmt, matching
the contract of every other Zero command.
New features:
- zero fmt --write <file> overwrites the file in place
- zero fmt --check --json emits { schemaVersion, command, mode, sourceFile, ok, unformatted }
- zero fmt --write --json emits { schemaVersion, command, mode, sourceFile, ok, written }
- --check and --write are mutually exclusive (error in both text and json modes)
- Bare zero fmt still prints to stdout (backward compat)
Text mode for --check is unchanged (fmt ok / format differs).
Closes vercel-labs#9
|
@gke0op is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
--writeflag and--jsonenvelope support tozero fmt, matching the contract of every other Zero command.New features
zero fmt --write <file>overwrites the file in placezero fmt --check --jsonemits structured envelope withokandunformattedzero fmt --write --jsonemits structured envelope withokandwritten--checkand--writeare mutually exclusive (error in both text and json modes)zero fmtstill prints to stdout (backward compatible)JSON envelope shape
{ "schemaVersion": 1, "command": "fmt", "mode": "check", "sourceFile": "examples/hello.0", "ok": true }When unformatted:
{ "schemaVersion": 1, "command": "fmt", "mode": "check", "sourceFile": "/tmp/messy.0", "ok": false, "unformatted": ["/tmp/messy.0"] }Changes
fmt_writefield toCommandstruct--writeflag parsing--checkand--write--checkmode (was previously ignored)--writemodeTesting
All existing tests pass (9 CLI, 8 docs, command contracts).
Manual verification:
zero fmt --check examples/hello.0→ exit 0zero fmt --check /tmp/messy.0→ exit 1 with "format differs"zero fmt --check --json /tmp/messy.0→ envelope with ok:false, exit 1zero fmt --write /tmp/messy.0→ rewrites file, prints "formatted: "zero fmt --write --json /tmp/messy.0→ envelope with ok:truezero fmt --check --write file.0→ mutual exclusivity errorzero fmt file.0→ still prints to stdout (backward compat)Closes #9