Skip to content

feat: markdown by default, --json for structured#7

Merged
DTTerastar merged 1 commit into
mainfrom
feat/markdown-default
Apr 25, 2026
Merged

feat: markdown by default, --json for structured#7
DTTerastar merged 1 commit into
mainfrom
feat/markdown-default

Conversation

@DTTerastar
Copy link
Copy Markdown
Collaborator

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

  • servings## per date, ### per food (group · name · qty), bullets for non-zero nutrients. Uses reflection over the typed struct and splits CamelCase suffixes (EnergyKcalEnergy (kcal), B12MgB12 (mg)).
  • nutrition## per date, alphabetical bullets for non-zero columns.
  • biometrics## per date, bullet per metric (Metric: amount unit).
  • exercises## per date, single line per session (Running, 30 min, 320 kcal (Cardio)).
  • notes## per date with note body; falls back to dumping all non-empty fields if a Note column isn't present.

Markdown suppresses zero-valued nutrients to stay scannable; the trailer points users at --json for the full row.

Touchpoints

  • New cmd/format.go with AddFormatFlags, emit(cmd, kind, v), and per-kind renderers.
  • Every subcommand registers the new flags and calls emit(...) in place of the old emitJSON(...).
  • prime, root --help, and the README updated to describe the new contract.

Live samples

crono-export nutrition --today (default markdown):

## 2026-04-25
- B12 (Cobalamin) (µg): 3.27
- Calcium (mg): 177.83
- Carbs (g): 75.72
- Cholesterol (mg): 569.46
- Energy (kcal): 1576.25
- Fat (g): 100.92
- Fiber (g): 6.38
- Iron (mg): 6.09
- Protein (g): 99.42
…

crono-export biometrics --days 30:

## 2026-04-10
- Weight: 237 lbs

Test plan

  • go build ./... clean
  • go vet ./... clean
  • nutrition --today renders markdown with zero-suppressed bullets
  • servings --today renders per-date / per-food sections with non-zero nutrients
  • biometrics --days 30 renders per-date bullets with metric/unit
  • nutrition --today --json and --format json both still emit full pretty-printed JSON
  • nutrition --today --format bogus exits non-zero with a clear message
  • --help on every subcommand lists --format and --json
  • crono-export prime updated to describe both formats
  • Eyeball: have an agent call commands without --json and see if the output is more useful in chat

🤖 Generated with Claude Code

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>
@DTTerastar DTTerastar merged commit 38f1fcd into main Apr 25, 2026
1 check passed
@DTTerastar DTTerastar deleted the feat/markdown-default branch May 19, 2026 04:03
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.

1 participant