Skip to content

refactor(cli): migrate from Kong to Cobra#785

Merged
cpcloud merged 3 commits intomainfrom
worktree-jiggly-gliding-eich
Mar 17, 2026
Merged

refactor(cli): migrate from Kong to Cobra#785
cpcloud merged 3 commits intomainfrom
worktree-jiggly-gliding-eich

Conversation

@cpcloud
Copy link
Owner

@cpcloud cpcloud commented Mar 17, 2026

Summary

  • Replace alecthomas/kong with spf13/cobra for CLI argument parsing
  • Built-in shell completion generation replaces 170 lines of hand-written bash/zsh/fish scripts
  • Lipgloss-styled --help output using Wong palette colors via custom helpFunc
  • Run functions accept io.Writer from cmd.OutOrStdout() for in-process testability
  • CLI tests use executeCLI() helper instead of building a binary, dropping cmd/micasa test time from ~10s to ~100ms
  • Update vendorHash in flake.nix for changed go.sum

🤖 Generated with Claude Code

Replace alecthomas/kong with spf13/cobra for argument parsing. This
gives us built-in shell completion generation (replacing 170 lines of
hand-written scripts) and lipgloss-styled help output via a custom
helpFunc using the Wong palette.

Key changes:
- Root command is the TUI launcher; subcommands (backup, config,
  completion) attach as children -- identical behavior to Kong's
  default:"withargs"
- Run functions accept io.Writer from cmd.OutOrStdout() so tests can
  capture output in-process without building a binary
- Config edit and backup accept injectable parameters (config path,
  env DB path) for testability
- CLI tests run in-process via executeCLI() helper, dropping test time
  from ~10s to ~100ms by eliminating 4 redundant go build invocations
- Only TestVersion_DevShowsCommitHash still needs a real binary (for
  VCS info), built lazily via sync.Once

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 56.83761% with 101 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.54%. Comparing base (7b9d5dc) to head (1994de6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/micasa/help.go 0.00% 59 Missing ⚠️
cmd/micasa/main.go 72.00% 34 Missing and 8 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
cmd/micasa/completion.go 100.00% <100.00%> (ø)
cmd/micasa/main.go 47.64% <72.00%> (+44.45%) ⬆️
cmd/micasa/help.go 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

cpcloud and others added 2 commits March 17, 2026 08:30
Handle errcheck on fmt.Fprint/Fprintln calls, replace exec.Command with
exec.CommandContext, rename unused parameters to _, and remove unused
envWithEditor function.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Document the implicit MICASA_DB_PATH env var contract on resolveDBPath
and extract resolveBackupSource to consolidate two-path source logic
into a single method. Remove t.Parallel from TestVersion_Injected to
prevent a data race on the mutable version global, add TestMain for
test binary cleanup, use context.WithTimeout in getTestBin for real
cancellation value, and unify errcheck suppression style to _, _ =
across all CLI files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cpcloud cpcloud merged commit e085133 into main Mar 17, 2026
25 checks passed
@cpcloud cpcloud deleted the worktree-jiggly-gliding-eich branch March 17, 2026 13:00
cpcloud added a commit that referenced this pull request Mar 19, 2026
…nd sync device management

Add the non-CLI foundation for micasa pro commands:

- crypto: SaveDeviceToken/LoadDeviceToken with atomic writes and 0600 perms
- sync: NewManagementClient constructor for management-only calls
- sync: Client methods for all relay endpoints (CreateHousehold, Invite,
  Join, Status, ListDevices, RevokeDevice, key exchange)
- data: RelayURL field on SyncDevice, GetSyncDevice/UpdateSyncDevice/
  UpdateOplogDeviceIDs store methods, GormDB accessor for sync layer

CLI wiring deferred until #785 (Cobra migration) merges.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cpcloud added a commit that referenced this pull request Mar 19, 2026
…nd sync device management

Add the non-CLI foundation for micasa pro commands:

- crypto: SaveDeviceToken/LoadDeviceToken with atomic writes and 0600 perms
- sync: NewManagementClient constructor for management-only calls
- sync: Client methods for all relay endpoints (CreateHousehold, Invite,
  Join, Status, ListDevices, RevokeDevice, key exchange)
- data: RelayURL field on SyncDevice, GetSyncDevice/UpdateSyncDevice/
  UpdateOplogDeviceIDs store methods, GormDB accessor for sync layer

CLI wiring deferred until #785 (Cobra migration) merges.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cpcloud added a commit that referenced this pull request Mar 19, 2026
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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