docs: plan CLI style alignment for missing commands
- commit
- 831aeb62adcf74e84947296045c275b729b7c8b2
- author
- brice · · 2026-02-10 06:08 UTC
- parent
- 9f6447c
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +96 -0
A docs/cli-style-alignment-plan.md +96 -0
| @@ -0,0 +1,96 @@ | |||
| 1 | + | # CLI Style Alignment Plan (Missing Commands) | |
| 2 | + | ||
| 3 | + | This plan targets CLI commands/subcommands that currently do not use `internal/cli/styles` renderers and also do not use Charmbracelet TUI packages (`lipgloss`, `bubbles`, `bubbletea`) in their execution path. | |
| 4 | + | ||
| 5 | + | Excluded by request: `help`, `completion`, `gen-docs`, `browse`. | |
| 6 | + | ||
| 7 | + | ## Scope | |
| 8 | + | ||
| 9 | + | Commands/subcommands to align: | |
| 10 | + | ||
| 11 | + | - `dumber config open` | |
| 12 | + | - `dumber crashes show <report|latest>` | |
| 13 | + | - `dumber crashes issue <report|latest>` | |
| 14 | + | - `dumber sessions list` | |
| 15 | + | - `dumber sessions restore <session-id>` | |
| 16 | + | - `dumber sessions delete <session-id>` | |
| 17 | + | ||
| 18 | + | Non-goals: | |
| 19 | + | ||
| 20 | + | - No changes to use cases, repositories, or adapters. | |
| 21 | + | - No changes to output formats for `--json` flags. | |
| 22 | + | ||
| 23 | + | ## Approach | |
| 24 | + | ||
| 25 | + | 1. Add small, focused renderers under `internal/cli/styles/` for these command outputs. | |
| 26 | + | 2. Update the Cobra handlers in `internal/cli/cmd/` to use those renderers for: | |
| 27 | + | - Success messages | |
| 28 | + | - “not found / nothing to do” messages | |
| 29 | + | - User-facing errors (print styled message and return `nil`, consistent with existing commands like `config status`) | |
| 30 | + | 3. Keep “raw content” outputs raw where users likely pipe/copy them (crash report markdown), and only style surrounding framing text. | |
| 31 | + | ||
| 32 | + | ## Proposed Renderer Additions | |
| 33 | + | ||
| 34 | + | - `internal/cli/styles/sessions_cli.go` | |
| 35 | + | - `type SessionsCLIRenderer struct { theme *Theme }` | |
| 36 | + | - `RenderListHeader(limit int) string` | |
| 37 | + | - `RenderListEmpty() string` | |
| 38 | + | - `RenderListRow(info entity.SessionInfo) string` (status icon + counts + relative time styling) | |
| 39 | + | - `RenderRestoreStarted(sessionID string) string` | |
| 40 | + | - `RenderDeleteOK(sessionID string) string` | |
| 41 | + | - `RenderError(err error) string` | |
| 42 | + | ||
| 43 | + | - `internal/cli/styles/crashes_cli.go` | |
| 44 | + | - `type CrashesCLIRenderer struct { theme *Theme }` | |
| 45 | + | - `RenderShowHeader(id string, generatedAt string) string` (optional) | |
| 46 | + | - `RenderIssueHeader(id string) string` (optional, default off if it would break copy/paste) | |
| 47 | + | - `RenderError(err error) string` | |
| 48 | + | ||
| 49 | + | - `internal/cli/styles/config_cli.go` (or extend existing `config.go`) | |
| 50 | + | - Add `RenderOpening(path, editor string) string` | |
| 51 | + | - Add `RenderOpenHint(path string) string` (e.g., when file missing) | |
| 52 | + | - Reuse `RenderError(err)` from `ConfigRenderer` | |
| 53 | + | ||
| 54 | + | ## Command Changes | |
| 55 | + | ||
| 56 | + | - `internal/cli/cmd/config.go` | |
| 57 | + | - In `runConfigOpen`: | |
| 58 | + | - Use `styles.NewConfigRenderer(app.Theme)` (requires `GetApp()`/theme). | |
| 59 | + | - Print styled “opening …” message (optional). | |
| 60 | + | - For user-facing failures (missing config, missing editor), print renderer error/hint and return `nil` so Cobra doesn’t print a second unstyled error. | |
| 61 | + | ||
| 62 | + | - `internal/cli/cmd/crashes.go` | |
| 63 | + | - In `runCrashesShow` / `runCrashesIssue`: | |
| 64 | + | - Use a new `CrashesCLIRenderer` for framing/errors. | |
| 65 | + | - Keep the markdown body as-is on stdout. | |
| 66 | + | ||
| 67 | + | - `internal/cli/cmd/sessions.go` | |
| 68 | + | - In `runSessionsList`: | |
| 69 | + | - Keep `--json` identical. | |
| 70 | + | - Replace plain tabwriter output with themed lines (or a boxed, fixed-width table) produced by `SessionsCLIRenderer`. | |
| 71 | + | - In `runSessionsRestore` / `runSessionsDelete`: | |
| 72 | + | - Replace plain `fmt.Printf` success lines with themed status lines using icons from `internal/cli/styles/icons.go`. | |
| 73 | + | - Style user-facing errors similarly (print and return `nil`). | |
| 74 | + | ||
| 75 | + | ## Tests | |
| 76 | + | ||
| 77 | + | Add renderer unit tests (no bubbletea runtime needed): | |
| 78 | + | ||
| 79 | + | - `internal/cli/styles/sessions_cli_test.go` | |
| 80 | + | - `internal/cli/styles/crashes_cli_test.go` | |
| 81 | + | - `internal/cli/styles/config_cli_test.go` (if adding new config-open rendering) | |
| 82 | + | ||
| 83 | + | Test strategy: | |
| 84 | + | ||
| 85 | + | - Use `styles.NewTheme(config.DefaultConfig())` to build a theme. | |
| 86 | + | - Assert key substrings are present (icons, command nouns, session IDs), avoiding strict ANSI comparisons. | |
| 87 | + | ||
| 88 | + | ## Verification | |
| 89 | + | ||
| 90 | + | - `go test ./...` | |
| 91 | + | - `make lint` | |
| 92 | + | - Manual smoke: | |
| 93 | + | - `go run ./cmd/dumber sessions list` | |
| 94 | + | - `go run ./cmd/dumber sessions delete <id>` | |
| 95 | + | - `go run ./cmd/dumber crashes show latest` | |
| 96 | + | ||
| @@ -0,0 +1,96 @@ | |||||
| 1 | + | # CLI Style Alignment Plan (Missing Commands) | |||
| 2 | + | ||||
| 3 | + | This plan targets CLI commands/subcommands that currently do not use `internal/cli/styles` renderers and also do not use Charmbracelet TUI packages (`lipgloss`, `bubbles`, `bubbletea`) in their execution path. | |||
| 4 | + | ||||
| 5 | + | Excluded by request: `help`, `completion`, `gen-docs`, `browse`. | |||
| 6 | + | ||||
| 7 | + | ## Scope | |||
| 8 | + | ||||
| 9 | + | Commands/subcommands to align: | |||
| 10 | + | ||||
| 11 | + | - `dumber config open` | |||
| 12 | + | - `dumber crashes show <report|latest>` | |||
| 13 | + | - `dumber crashes issue <report|latest>` | |||
| 14 | + | - `dumber sessions list` | |||
| 15 | + | - `dumber sessions restore <session-id>` | |||
| 16 | + | - `dumber sessions delete <session-id>` | |||
| 17 | + | ||||
| 18 | + | Non-goals: | |||
| 19 | + | ||||
| 20 | + | - No changes to use cases, repositories, or adapters. | |||
| 21 | + | - No changes to output formats for `--json` flags. | |||
| 22 | + | ||||
| 23 | + | ## Approach | |||
| 24 | + | ||||
| 25 | + | 1. Add small, focused renderers under `internal/cli/styles/` for these command outputs. | |||
| 26 | + | 2. Update the Cobra handlers in `internal/cli/cmd/` to use those renderers for: | |||
| 27 | + | - Success messages | |||
| 28 | + | - “not found / nothing to do” messages | |||
| 29 | + | - User-facing errors (print styled message and return `nil`, consistent with existing commands like `config status`) | |||
| 30 | + | 3. Keep “raw content” outputs raw where users likely pipe/copy them (crash report markdown), and only style surrounding framing text. | |||
| 31 | + | ||||
| 32 | + | ## Proposed Renderer Additions | |||
| 33 | + | ||||
| 34 | + | - `internal/cli/styles/sessions_cli.go` | |||
| 35 | + | - `type SessionsCLIRenderer struct { theme *Theme }` | |||
| 36 | + | - `RenderListHeader(limit int) string` | |||
| 37 | + | - `RenderListEmpty() string` | |||
| 38 | + | - `RenderListRow(info entity.SessionInfo) string` (status icon + counts + relative time styling) | |||
| 39 | + | - `RenderRestoreStarted(sessionID string) string` | |||
| 40 | + | - `RenderDeleteOK(sessionID string) string` | |||
| 41 | + | - `RenderError(err error) string` | |||
| 42 | + | ||||
| 43 | + | - `internal/cli/styles/crashes_cli.go` | |||
| 44 | + | - `type CrashesCLIRenderer struct { theme *Theme }` | |||
| 45 | + | - `RenderShowHeader(id string, generatedAt string) string` (optional) | |||
| 46 | + | - `RenderIssueHeader(id string) string` (optional, default off if it would break copy/paste) | |||
| 47 | + | - `RenderError(err error) string` | |||
| 48 | + | ||||
| 49 | + | - `internal/cli/styles/config_cli.go` (or extend existing `config.go`) | |||
| 50 | + | - Add `RenderOpening(path, editor string) string` | |||
| 51 | + | - Add `RenderOpenHint(path string) string` (e.g., when file missing) | |||
| 52 | + | - Reuse `RenderError(err)` from `ConfigRenderer` | |||
| 53 | + | ||||
| 54 | + | ## Command Changes | |||
| 55 | + | ||||
| 56 | + | - `internal/cli/cmd/config.go` | |||
| 57 | + | - In `runConfigOpen`: | |||
| 58 | + | - Use `styles.NewConfigRenderer(app.Theme)` (requires `GetApp()`/theme). | |||
| 59 | + | - Print styled “opening …” message (optional). | |||
| 60 | + | - For user-facing failures (missing config, missing editor), print renderer error/hint and return `nil` so Cobra doesn’t print a second unstyled error. | |||
| 61 | + | ||||
| 62 | + | - `internal/cli/cmd/crashes.go` | |||
| 63 | + | - In `runCrashesShow` / `runCrashesIssue`: | |||
| 64 | + | - Use a new `CrashesCLIRenderer` for framing/errors. | |||
| 65 | + | - Keep the markdown body as-is on stdout. | |||
| 66 | + | ||||
| 67 | + | - `internal/cli/cmd/sessions.go` | |||
| 68 | + | - In `runSessionsList`: | |||
| 69 | + | - Keep `--json` identical. | |||
| 70 | + | - Replace plain tabwriter output with themed lines (or a boxed, fixed-width table) produced by `SessionsCLIRenderer`. | |||
| 71 | + | - In `runSessionsRestore` / `runSessionsDelete`: | |||
| 72 | + | - Replace plain `fmt.Printf` success lines with themed status lines using icons from `internal/cli/styles/icons.go`. | |||
| 73 | + | - Style user-facing errors similarly (print and return `nil`). | |||
| 74 | + | ||||
| 75 | + | ## Tests | |||
| 76 | + | ||||
| 77 | + | Add renderer unit tests (no bubbletea runtime needed): | |||
| 78 | + | ||||
| 79 | + | - `internal/cli/styles/sessions_cli_test.go` | |||
| 80 | + | - `internal/cli/styles/crashes_cli_test.go` | |||
| 81 | + | - `internal/cli/styles/config_cli_test.go` (if adding new config-open rendering) | |||
| 82 | + | ||||
| 83 | + | Test strategy: | |||
| 84 | + | ||||
| 85 | + | - Use `styles.NewTheme(config.DefaultConfig())` to build a theme. | |||
| 86 | + | - Assert key substrings are present (icons, command nouns, session IDs), avoiding strict ANSI comparisons. | |||
| 87 | + | ||||
| 88 | + | ## Verification | |||
| 89 | + | ||||
| 90 | + | - `go test ./...` | |||
| 91 | + | - `make lint` | |||
| 92 | + | - Manual smoke: | |||
| 93 | + | - `go run ./cmd/dumber sessions list` | |||
| 94 | + | - `go run ./cmd/dumber sessions delete <id>` | |||
| 95 | + | - `go run ./cmd/dumber crashes show latest` | |||
| 96 | + | ||||