feat: markdown by default, --json for structured#7
Merged
Conversation
Per a feedback session: agents calling this CLI as a tool tend to do
better with narrow markdown they can read inline than with raw JSON.
Switch the default output to fitdown-style markdown — date-grouped
headings, one bullet per non-zero field, no wide tables — and add
--json (or --format json) for the structured shape that pipes well to
jq.
Layout per endpoint:
servings ## per date, ### per food (group · name · qty), bullets
for non-zero nutrients (uses reflection over the typed
struct, splits CamelCase suffixes for units).
nutrition ## per date, bullets for non-zero columns; alpha sort.
biometrics ## per date, bullet per metric (Metric: amount unit).
exercises ## per date, single line per session.
notes ## per date with note body; falls back to dumping all
non-empty fields if a Note column isn't found.
Markdown drops zero-valued nutrients to keep output scannable; the
trailer points users at --json for the full row.
Wired through a small format.go (AddFormatFlags + emit + per-kind
renderers) and updated each subcommand to call emit(cmd, kind, v).
prime, root --help, and the README were all updated to describe the
new contract.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Default output is now narrow, Fitdown-style markdown — date-grouped headings, one bullet per non-zero field, no wide tables. Pass
--json(or--format json) for the full structured row.This is a breaking change to the CLI's contract: any script or agent that pipes
crono-export X | jq …will need to add--json. The reasoning: agents handling the output inline read narrow markdown better than raw JSON, and human users running it ad-hoc in a terminal get a readable result instead of a wall of JSON.Layout per endpoint
##per date,###per food (group · name · qty), bullets for non-zero nutrients. Uses reflection over the typed struct and splits CamelCase suffixes (EnergyKcal→Energy (kcal),B12Mg→B12 (mg)).##per date, alphabetical bullets for non-zero columns.##per date, bullet per metric (Metric: amount unit).##per date, single line per session (Running, 30 min, 320 kcal (Cardio)).##per date with note body; falls back to dumping all non-empty fields if aNotecolumn isn't present.Markdown suppresses zero-valued nutrients to stay scannable; the trailer points users at
--jsonfor the full row.Touchpoints
cmd/format.gowithAddFormatFlags,emit(cmd, kind, v), and per-kind renderers.emit(...)in place of the oldemitJSON(...).prime, root--help, and the README updated to describe the new contract.Live samples
crono-export nutrition --today(default markdown):crono-export biometrics --days 30:Test plan
go build ./...cleango vet ./...cleannutrition --todayrenders markdown with zero-suppressed bulletsservings --todayrenders per-date / per-food sections with non-zero nutrientsbiometrics --days 30renders per-date bullets with metric/unitnutrition --today --jsonand--format jsonboth still emit full pretty-printed JSONnutrition --today --format bogusexits non-zero with a clear message--helpon every subcommand lists--formatand--jsoncrono-export primeupdated to describe both formats--jsonand see if the output is more useful in chat🤖 Generated with Claude Code