feat(cli): default amy stdout to human-readable text; --json opts in
amy's default stdout is now a YAML-ish render of the underlying result
map; the previous single-line JSON contract moves behind a global
`--json` flag. Errors mirror the same rule (`error: <code>: <detail>`
on stderr by default, JSON `{"error":...,"detail":...}` under --json).
Exit codes (0/1/2/124) and the --json shape itself are unchanged —
only the default presentation flips.
- Replaces Json.writeLine / Json.error with mode-aware
Output.emit / Output.error. The same Jackson mapper is reused for
on-disk JSON via Output.mapper.
- Adds `--json` to the global flag set in Main.kt; honoured even when
argument parsing fails so error JSON keeps shape under --json.
- Updates the test harness wrappers (amy_a / amy_b / amy_d in
cli/tests/{headless,dm,cache}/) and the few direct $AMY_BIN call
sites whose stdout is consumed via $() / 2>&1 — they now pass
--json so the existing jq pipelines keep working.
- Rewrites the README "Output contract" and DEVELOPMENT design
principles to describe the new default, and clarifies that only
--json is the public API; the text shape is allowed to drift.
This commit is contained in:
Vendored
+5
-5
@@ -81,7 +81,7 @@ source "$TESTS_DIR/headless/helpers.sh"
|
||||
# shellcheck source=../dm/setup.sh
|
||||
source "$TESTS_DIR/dm/setup.sh"
|
||||
|
||||
amy_b() { "$AMY_BIN" --data-dir "$B_DIR" "$@"; }
|
||||
amy_b() { "$AMY_BIN" --data-dir "$B_DIR" --json "$@"; }
|
||||
|
||||
# Helper: B-side amy_json. The dm headless's helpers.sh hardcodes A_DIR
|
||||
# in amy_a; we need a parallel for B without re-sourcing.
|
||||
@@ -249,10 +249,10 @@ fi
|
||||
# ----------------------------------------------------------------------
|
||||
banner "T7 — store maintenance verbs (sweep/scrub/compact) without identity"
|
||||
TMP_NO_ID=$(mktemp -d)
|
||||
T7_STAT=$(${AMY_BIN} --data-dir "$TMP_NO_ID" store stat)
|
||||
T7_SWEEP=$(${AMY_BIN} --data-dir "$TMP_NO_ID" store sweep-expired)
|
||||
T7_SCRUB=$(${AMY_BIN} --data-dir "$TMP_NO_ID" store scrub)
|
||||
T7_COMPACT=$(${AMY_BIN} --data-dir "$TMP_NO_ID" store compact)
|
||||
T7_STAT=$(${AMY_BIN} --data-dir "$TMP_NO_ID" --json store stat)
|
||||
T7_SWEEP=$(${AMY_BIN} --data-dir "$TMP_NO_ID" --json store sweep-expired)
|
||||
T7_SCRUB=$(${AMY_BIN} --data-dir "$TMP_NO_ID" --json store scrub)
|
||||
T7_COMPACT=$(${AMY_BIN} --data-dir "$TMP_NO_ID" --json store compact)
|
||||
assert_eq "$(printf '%s' "$T7_STAT" | jq -r '.events')" "0" T7.stat.events "" \
|
||||
&& record_result T7.stat pass "stat works without identity"
|
||||
assert_eq "$(printf '%s' "$T7_SWEEP" | jq -r '.swept')" "0" T7.sweep.swept "" \
|
||||
|
||||
Reference in New Issue
Block a user