Skip to content

refactor(cli): split main.go into per-command files - #7

Merged
ironystock merged 1 commit into
mainfrom
refactor/cmd-rememberize-split
Apr 28, 2026
Merged

ironystock merged 1 commit into
mainfrom
refactor/cmd-rememberize-split

Conversation

@ironystock

@ironystock ironystock commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Splits cmd/rememberize/main.go (940 lines, 13 cobra commands + shared helpers) into per-command files alongside the existing pair.go / config.go / client.go pattern.
  • Shared output helpers (printJSON, truncate, printSearchResults) move to a new render.go.
  • main.go shrinks to ~50 lines: root command, --json persistent flag, AddCommand wiring.

Context

First PR in the scaffolding + verbosity + Charmbracelet polish sprint (plan: ~/.claude/plans/peppy-forging-dahl.md). Pure code motion with zero behavior change — sets the stage so the upcoming PRs (logger, fang, lipgloss tables, huh prompts) each diff cleanly against one command file at a time instead of piling on a 1k-line monolith.

Files

cmd/rememberize/
  main.go          (was 940, now 49 lines: root + init + main only)
  add.go           NEW
  recall.go        NEW
  search.go        NEW
  list.go          NEW
  get.go           NEW
  rm.go            NEW
  namespaces.go    NEW
  connections.go   NEW
  audit.go         NEW
  configcmd.go     NEW (config command — sibling of the existing config.go data-layer file)
  import.go        NEW
  export.go        NEW
  keys.go          NEW (all 3 subcommands together)
  render.go        NEW (printJSON, truncate, printSearchResults)
  client.go        unchanged
  config.go        unchanged
  pair.go          unchanged
  pair_test.go     unchanged
  pair_flow_test.go unchanged

Verification

  • go build ./... clean.
  • go test ./... green (pair tests untouched, exercise the same code paths).
  • go vet ./... clean.
  • ./bin/rememberize --help lists the same 13 commands in the same order.
  • ./bin/rememberize --version reports rememberize version dev as before.

Test plan

  • CI green (build + test on linux/macos/windows + golangci-lint v2.11.4 + cross-platform release dry-run).
  • Reviewer scans git diff --stat to confirm the diff is dominated by motion (insertions ≈ deletions).

Out of scope

No new dependencies, no behavior change, no test changes. The next PR introduces charmbracelet/log + --verbose/--quiet flags.

🤖 Generated with Claude Code


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

main.go was 940 lines holding 13 cobra commands plus shared output
helpers. Each command now lives in its own file alongside the existing
pair.go/config.go/client.go pattern; shared output helpers (printJSON,
truncate, printSearchResults) move to render.go. main.go shrinks to
~50 lines: root command, --json persistent flag, AddCommand wiring.

Pure motion. Behavior, flags, output text all unchanged. Sets the
stage for upcoming verbosity (charmbracelet/log) and TUI polish
(charmbracelet/fang, lipgloss tables, huh prompts) without piling
each onto a single 1k-line file.

go build ./... clean. go test ./... green.
./bin/rememberize --help lists the same 13 commands in same order.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@ironystock
ironystock merged commit b71c2b9 into main Apr 28, 2026
6 checks passed
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