Skip to content

fix: audit and fix all CLI commands#5

Merged
karngyan merged 1 commit intomainfrom
fix-update-command
Apr 6, 2026
Merged

fix: audit and fix all CLI commands#5
karngyan merged 1 commit intomainfrom
fix-update-command

Conversation

@karngyan
Copy link
Copy Markdown
Member

@karngyan karngyan commented Apr 6, 2026

Audited every command. Six fixes:

clipx update — detect install method

Before: hardcoded go install. Broke for Homebrew users (no Go installed) or silently installed a second binary.

Now: detects how clipx was installed by checking the binary path:

  • Cellar/homebrew in path → brew upgrade clipx
  • $GOPATH/bingo install ...@latest
  • Anything else → prints link to releases page

clipx status — fix status indicator

Before: ● clipx is not running implies active/healthy.
Now: ○ clipx is not running.

clipx install — honest firewall reporting

Before: always printed ✓ firewall exception added even if user cancelled sudo.
Now: checks error codes, prints ⚠ firewall exception failed if it didn't work.

clipx pair/unpair — auto-restart

Before: restart clipx or run 'clipx install' to apply.
Now: if LaunchAgent is running, restarts it automatically.

Unknown commands

Before: clipx foo silently started the daemon.
Now: unknown command: foo + run 'clipx help' for usage.

All extracted into a shared restartIfRunning() helper used by pair, unpair, and update.

- update: detect install method (brew/go/binary) and use the right
  updater. Homebrew users get 'brew upgrade', go install users get
  'go install', manual installs get a link to releases.
- status: use ○ for 'not running' instead of ● (which implies active)
- install: report firewall failure honestly instead of always printing ✓
- pair/unpair: auto-restart LaunchAgent if running, instead of telling
  the user to do it manually
- unknown commands: error with 'run clipx help' instead of silently
  starting the daemon
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

📊 Code Coverage Report

total:								(statements)		24.9%
Coverage by file
github.com/gomantics/clipx/cmd/clipx/main.go:21:		getVersion		0.0%
github.com/gomantics/clipx/cmd/clipx/main.go:31:		main			0.0%
github.com/gomantics/clipx/cmd/clipx/main.go:78:		printUsage		0.0%
github.com/gomantics/clipx/cmd/clipx/main.go:103:		cmdRun			0.0%
github.com/gomantics/clipx/cmd/clipx/main.go:136:		cmdPair			0.0%
github.com/gomantics/clipx/cmd/clipx/main.go:165:		cmdUnpair		0.0%
github.com/gomantics/clipx/cmd/clipx/main.go:202:		cmdPeers		0.0%
github.com/gomantics/clipx/cmd/clipx/main.go:217:		cmdStatus		0.0%
github.com/gomantics/clipx/cmd/clipx/main.go:246:		detectInstallMethod	0.0%
github.com/gomantics/clipx/cmd/clipx/main.go:269:		cmdUpdate		0.0%
github.com/gomantics/clipx/cmd/clipx/main.go:311:		restartIfRunning	0.0%
github.com/gomantics/clipx/cmd/clipx/main.go:354:		launchAgentPath		0.0%
github.com/gomantics/clipx/cmd/clipx/main.go:359:		logFilePath		0.0%
github.com/gomantics/clipx/cmd/clipx/main.go:364:		cmdInstall		0.0%
github.com/gomantics/clipx/cmd/clipx/main.go:419:		cmdUninstall		0.0%
github.com/gomantics/clipx/internal/clipx/clipboard.go:49:	Read			0.0%
github.com/gomantics/clipx/internal/clipx/clipboard.go:55:	Write			0.0%
github.com/gomantics/clipx/internal/clipx/config.go:16:		ConfigPath		100.0%
github.com/gomantics/clipx/internal/clipx/config.go:22:		LoadConfig		77.8%
github.com/gomantics/clipx/internal/clipx/config.go:38:		SaveConfig		71.4%
github.com/gomantics/clipx/internal/clipx/net.go:15:		ResolveAddr		88.9%
github.com/gomantics/clipx/internal/clipx/net.go:35:		PingPeer		0.0%
github.com/gomantics/clipx/internal/clipx/node.go:50:		NewNode			0.0%
github.com/gomantics/clipx/internal/clipx/node.go:55:		NewNodeWithClipboard	0.0%
github.com/gomantics/clipx/internal/clipx/node.go:88:		Start			0.0%
github.com/gomantics/clipx/internal/clipx/node.go:97:		Stop			0.0%
github.com/gomantics/clipx/internal/clipx/node.go:106:		connectPeer		0.0%
github.com/gomantics/clipx/internal/clipx/node.go:117:		sendToPeer		0.0%
github.com/gomantics/clipx/internal/clipx/node.go:145:		listen			83.3%
github.com/gomantics/clipx/internal/clipx/node.go:195:		handleClip		75.0%
github.com/gomantics/clipx/internal/clipx/node.go:203:		handleChunk		81.5%
github.com/gomantics/clipx/internal/clipx/node.go:254:		applyClipboard		85.7%
github.com/gomantics/clipx/internal/clipx/node.go:278:		watchClipboard		0.0%
github.com/gomantics/clipx/internal/clipx/node.go:323:		sendToAllPeers		0.0%
github.com/gomantics/clipx/internal/clipx/node.go:374:		maintenance		0.0%
github.com/gomantics/clipx/internal/clipx/node.go:407:		clipPreview		100.0%
github.com/gomantics/clipx/internal/clipx/node.go:416:		isTimeout		0.0%
github.com/gomantics/clipx/internal/clipx/node.go:423:		isConnectionError	0.0%
github.com/gomantics/clipx/internal/clipx/protocol.go:47:	encodeMessage		100.0%
github.com/gomantics/clipx/internal/clipx/protocol.go:58:	decodeMessage		100.0%
github.com/gomantics/clipx/internal/clipx/protocol.go:72:	encodeClipPayload	100.0%
github.com/gomantics/clipx/internal/clipx/protocol.go:81:	decodeClipPayload	100.0%
github.com/gomantics/clipx/internal/clipx/protocol.go:89:	encodeChunkPayload	100.0%
github.com/gomantics/clipx/internal/clipx/protocol.go:99:	decodeChunkPayload	100.0%
github.com/gomantics/clipx/internal/clipx/protocol.go:111:	HashContent		100.0%
total:								(statements)		24.9%

@karngyan karngyan merged commit 2ea5f3c into main Apr 6, 2026
2 checks passed
@karngyan karngyan deleted the fix-update-command branch April 6, 2026 13:18
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