Skip to content

Commit 38f1fcd

Browse files
authored
Merge pull request #7 from quantcli/feat/markdown-default
feat: markdown by default, --json for structured
2 parents 0503108 + c1a4879 commit 38f1fcd

9 files changed

Lines changed: 462 additions & 78 deletions

File tree

README.md

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# crono-export-cli
22

3-
Export your personal nutrition, biometric, and food-log data from [Cronometer](https://cronometer.com) as JSON. Built for personal LLM agents and scripts that want structured nutrition data — for example, an LLM-driven bariatric or fitness coach that needs to know how much protein, B12, iron, or calcium you actually got today.
3+
Export your personal nutrition, biometric, and food-log data from [Cronometer](https://cronometer.com) as narrow markdown (the default) or JSON. Built for personal LLM agents and scripts that want structured nutrition data — for example, an LLM-driven bariatric or fitness coach that needs to know how much protein, B12, iron, or calcium you actually got today.
44

55
[![Latest Release](https://img.shields.io/github/v/release/quantcli/crono-export-cli)](https://github.com/quantcli/crono-export-cli/releases/latest)
66
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
@@ -10,7 +10,7 @@ Export your personal nutrition, biometric, and food-log data from [Cronometer](h
1010
## Features
1111

1212
- **Five export endpoints** — servings (per-food log with full nutrient breakdown), nutrition (daily totals), biometrics (weight, body fat, custom metrics), exercises, and notes
13-
- **JSON on stdout**pipe straight to `jq`, save to disk, or hand to an LLM tool
13+
- **Markdown by default, JSON on demand**narrow fitdown-style markdown reads well in chat and terminals; pass `--json` for the full structured row to pipe through `jq`
1414
- **Date selection**`--today`, `--days N`, or `--start YYYY-MM-DD --end YYYY-MM-DD` on every subcommand
1515
- **Single static binary** — no Python or Node runtime; drop it in `~/bin/` and go
1616
- **Credentials via env**`CRONOMETER_USERNAME` / `CRONOMETER_PASSWORD`, no config file needed
@@ -101,24 +101,20 @@ crono-export servings --days 7
101101
crono-export servings --start 2026-04-01 --end 2026-04-15
102102
```
103103

104-
Sample row (truncated):
105-
106-
```json
107-
{
108-
"RecordedTime": "2026-04-11T00:00:00Z",
109-
"Group": "Breakfast",
110-
"FoodName": "Cheese Cracker",
111-
"QuantityValue": 20,
112-
"QuantityUnits": "square",
113-
"EnergyKcal": 97.8,
114-
"ProteinG": 1.95,
115-
"CarbsG": 11.88,
116-
"FiberG": 0.46,
117-
"FatG": 4.94,
118-
"B12Mg": 0.07,
119-
"CalciumMg": 27.2,
120-
"IronMg": 0.69
121-
}
104+
Default markdown output (per food, zero-valued nutrients suppressed):
105+
106+
```markdown
107+
## 2026-04-11
108+
109+
### Breakfast · Cheese Cracker (20 square)
110+
- Energy: 97.8 kcal
111+
- Protein: 1.95 g
112+
- Carbs: 11.88 g
113+
- Fiber: 0.46 g
114+
- Fat: 4.94 g
115+
- B12: 0.07 mg
116+
- Calcium: 27.2 mg
117+
- Iron: 0.69 mg
122118
```
123119

124120
### Nutrition — daily totals
@@ -135,15 +131,9 @@ crono-export nutrition --days 30
135131
crono-export biometrics --days 30
136132
```
137133

138-
```json
139-
[
140-
{
141-
"RecordedTime": "2026-04-10T00:00:00Z",
142-
"Metric": "Weight",
143-
"Unit": "lbs",
144-
"Amount": 237
145-
}
146-
]
134+
```markdown
135+
## 2026-04-10
136+
- Weight: 237 lbs
147137
```
148138

149139
### Exercises
@@ -160,12 +150,17 @@ crono-export notes --days 30
160150

161151
## Output Format
162152

163-
Every subcommand prints pretty-printed JSON to stdout. Errors and progress messages go to stderr, so it's safe to pipe stdout into `jq`, redirect into a file, or feed to an LLM tool without worrying about mixed output.
153+
Default output is narrow, [Fitdown](https://github.com/datavis-tech/fitdown)-style markdown — date-grouped headings, one bullet per non-zero field, no wide tables. Markdown reads well in chat and on a terminal and is easy for an LLM to consume inline.
154+
155+
For programmatic use, pass `--json` (or `--format json`) to get the full structured row as a JSON array on stdout — nothing suppressed, easy to pipe through `jq`. Errors always go to stderr, so JSON output stays clean for piping.
164156

165157
```sh
166-
crono-export servings --today | jq '[.[] | {food: .FoodName, protein: .ProteinG}]'
158+
crono-export servings --today # markdown, default
159+
crono-export servings --today --json | jq '[.[] | {food: .FoodName, protein: .ProteinG}]'
167160
```
168161

162+
LLM agents: run `crono-export prime` for a one-screen orientation describing both formats, all subcommands, the date flags, and `jq` recipes.
163+
169164
## About Cronometer
170165

171166
[Cronometer](https://cronometer.com) is a nutrition tracking app with one of the best micronutrient databases of any consumer tool — a major reason it's commonly recommended for bariatric patients, anyone tracking specific vitamin/mineral targets, or athletes managing recovery nutrition.

cmd/biometrics.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ var biometricsCmd = &cobra.Command{
2424
if err != nil {
2525
return err
2626
}
27-
return emitJSON(recs)
27+
return emit(cmd, kindBiometrics, recs)
2828
},
2929
}
3030

3131
func init() {
3232
cronoclient.AddDateRangeFlags(biometricsCmd)
33+
AddFormatFlags(biometricsCmd)
3334
rootCmd.AddCommand(biometricsCmd)
3435
}

cmd/exercises.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ var exercisesCmd = &cobra.Command{
2424
if err != nil {
2525
return err
2626
}
27-
return emitJSON(recs)
27+
return emit(cmd, kindExercises, recs)
2828
},
2929
}
3030

3131
func init() {
3232
cronoclient.AddDateRangeFlags(exercisesCmd)
33+
AddFormatFlags(exercisesCmd)
3334
rootCmd.AddCommand(exercisesCmd)
3435
}

0 commit comments

Comments
 (0)