Commit 1fd01b7
feat(cli): add micasa status command for headless health checks (#930)
## Summary
- Add `micasa status [--json] [--days N] [database-path]` command for
non-TUI overdue/upcoming item checking
- Exit codes: 0 (nothing needs attention), 1 (error), 2 (items need
attention) — useful for cron jobs, shell prompts, status bar widgets
- Extract duration helpers from `dashboard.go`/`table.go` to
`internal/data/duration.go` (DRY)
## Reproduction steps
1. `micasa status` — text output showing overdue maintenance, open
incidents, active projects
2. `micasa status --json` — JSON output for scripting
3. `micasa status --days 7` — narrow look-ahead window
4. Check exit code: `micasa status; echo $?` — 0 if clean, 2 if items
need attention
## Changes
- `cmd/micasa/status.go` — cobra command with text/JSON rendering,
`--days`/`--json` flags
- `cmd/micasa/status_test.go` — 24 tests covering output formats, exit
codes, validation, sort order, error paths
- `cmd/micasa/main.go` — `exitError` sentinel type, `extractExitCode`,
custom fang error handler, command registration
- `internal/data/duration.go` — extracted `DateDiffDays`, `ShortDur`,
`DaysText`, `PastDur`
- `internal/data/duration_test.go` — duration helper unit tests (100%
coverage)
- `internal/app/dashboard.go` — delegates to `data.*` helpers
- `internal/app/table.go` — delegates `dateDiffDays` to
`data.DateDiffDays`
- `docs/content/docs/reference/cli.md` — regenerated CLI reference
Closes #692
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent d6372a5 commit 1fd01b7
15 files changed
Lines changed: 3597 additions & 53 deletions
File tree
- cmd/micasa
- docs/content/docs/reference
- internal
- app
- claudecli
- data
- plans
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
86 | 105 | | |
87 | 106 | | |
88 | 107 | | |
| |||
91 | 110 | | |
92 | 111 | | |
93 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
94 | 120 | | |
95 | 121 | | |
96 | 122 | | |
97 | 123 | | |
98 | | - | |
| 124 | + | |
99 | 125 | | |
100 | 126 | | |
101 | 127 | | |
| |||
0 commit comments