You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implemented finding F1 from `AGENT_NATIVE_AUDIT.md`. vers-cli now standardizes on `--json` across the entire command surface, with `--format` retained as a hidden, deprecated alias.
19 cobra `--format` registrations now have a sibling `--json` BoolVar; 19 `pres.ParseFormat` call sites now pass the JSON flag and propagate the validation error.
28
+
29
+
Commit: `6744100 feat: standardize on --json flag (deprecate --format json)` on branch `pi-parallel-d95f3d3f-0`.
30
+
31
+
## Design choices
32
+
33
+
1.**Centralized validation in `presenters.ParseFormat`.** New signature: `ParseFormat(quiet, jsonFlag bool, formatStr string) (OutputFormat, error)`. Precedence is `quiet > json > format > default`. Invalid `--format` values return an enumerated error rather than silently falling through to default-format (which was the previous behavior — a P3 violation).
34
+
2.**Cobra's `MarkDeprecated` handles the warning.** It prints `Flag --format has been deprecated, use --json instead` to stderr automatically when the flag is used, and hides the flag from `--help`. No custom warning code needed.
35
+
3.**Stdout/stderr separation preserved.** Deprecation warnings go to stderr; JSON data continues to land cleanly on stdout. `vers status --format json | jq` still works without contamination.
36
+
37
+
## Validation
38
+
39
+
-`go build ./...` — clean
40
+
-`go vet ./...` — clean
41
+
-`go test ./...` — all packages pass (including expanded `format_test.go` with 9 cases covering the new precedence and error semantics)
42
+
43
+
Smoke tests against built binary:
44
+
45
+
```
46
+
$ vers status --json
47
+
[] # exit 0, clean stdout
48
+
49
+
$ vers status --format json 2>/tmp/err
50
+
[] # exit 0, JSON on stdout
51
+
$ cat /tmp/err
52
+
Flag --format has been deprecated, use --json instead
53
+
54
+
$ vers status --format yaml
55
+
Flag --format has been deprecated, use --json instead
56
+
Error: --format must be "json" (got: "yaml"). Note: --format is deprecated, use --json instead
57
+
# exit 1
58
+
```
59
+
60
+
`vers status --help` no longer lists `--format`; long descriptions everywhere now read "Use --json for machine-readable output."
61
+
62
+
## Risks / open questions
63
+
64
+
-**Usage banner printed on RunE error.** When `--format yaml` is rejected, cobra prints the command's usage block after the error. This is pre-existing behavior — `SilenceUsage = true` is only set in the auth path in `cmd/root.go:210`. Out of scope for F1, but worth a follow-up if cleaner agent-facing errors are wanted (set `SilenceUsage = true` on the root command).
65
+
-**`alias` command is still missing JSON output entirely.** This is finding F2, separate task.
66
+
-**No tests assert deprecation warning emission to stderr.** The cobra `MarkDeprecated` behavior is library-provided and stable, so I didn't add an integration test capturing stderr; the unit tests exercise only the validation path. If desired, a small `cmd/`-level test could capture stderr from a `--format json` invocation.
67
+
68
+
## Recommended next step
69
+
70
+
Hand off to F2 (info → get) and F3 (pagination) as planned. After both land, audit the few commands that have a `--quiet` flag but no `--json` (`alias`, possibly `head`, `checkout`) and unify those — the `ParseFormat` machinery is already in place to extend them cheaply.
0 commit comments