Skip to content

feat(cli): add 'gander watch <file>' subcommand as alias for 'share --watch' - #67

Merged
scott merged 1 commit into
mainfrom
feat/65-gander-watch-subcommand
Aug 26, 2026
Merged

feat(cli): add 'gander watch <file>' subcommand as alias for 'share --watch'#67
scott merged 1 commit into
mainfrom
feat/65-gander-watch-subcommand

Conversation

@scott

@scott scott commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds gander watch <file.md> as a thin top-level shorthand for gander share <file.md> --watch (the canonical "live-share to gander.md on every save" flow).
  • New runWatchCmd in share.go delegates to the existing runShareWithCtx(..., ["--watch", file]), so auth, mapping writes, fsnotify + debounce + PUT-to-gandermd, and "Already shared … refreshing in place." are reused unchanged.
  • A header note in watch.go clarifies that the local runWatch (preview path, gander <file> --watch) and the new remote runWatchCmd (share path, gander watch <file>) are deliberately separate code paths despite sharing the watch name.
  • Help/usage: watch is listed under the authed block in printUsage and the unauthed hint now mentions it alongside share / remove / list / manage / auth.
  • Bash + zsh completions include the new watch subcommand.
  • README leads with gander watch README.md as the headline live-share example; gander share --watch is kept as the explicit-flag equivalent.
  • Man page (man/man1/gander.1) gains a synopsis entry, a Watch section, and an example. The existing TestManPageExistsAndRenders was extended to assert gander watch is rendered.

Related Issue

Closes #65

Testing

  • go test ./... — all green, including three new tests:
    • TestWatchCmdEqualsShareWatch — end-to-end: runWatchCmdWithCtx issues the same POST /api/shares body (watch: true), opens the share, then PUTs updates on save against a httptest.Server. Parallel to TestShareWatchFlowEndToEnd.
    • TestWatchCmdRequiresAuth — with no token in ~/.gander, returns requireAuth's "not signed up" error and makes zero network calls.
    • TestWatchCmdRejectsBadArgs — rejects zero and two positional args.
  • go vet ./... — clean.
  • go build ./... — clean.
  • CGO_ENABLED=0 go build -trimpath -ldflags "-X main.Version=…" -o gander . — produces a working binary; gander --help shows the new authed line and gander watch (with no args) prints the usage error.
  • Man page still lints clean with mandoc -Tlint.

Notes

  • runWatchCmd is paired with a runWatchCmdWithCtx variant (mirroring the existing runShare / runShareWithCtx split) so tests can cancel via context.
  • No server changes — gandermd accepts the same POST /api/shares body the CLI has been sending; the alias is purely a CLI-side ergonomic.
  • Coordinated landing for the docs/landing-page mirror will be tracked separately per the issue's "Pairing" note.

…-watch' (#65)

Wraps the existing runShare path with --watch forced, so agents and
humans can invoke the canonical live-share flow with one fewer token
(`gander watch README.md` vs `gander share README.md --watch`).

The new top-level command is listed in --help only when an API token
is present, and the unauthed hint now mentions watch alongside the
other gated commands. Both behaviors fall out for free because the
new handler delegates to runShareWithCtx, which calls requireAuth()
first.

- main.go: dispatcher case + authed printUsage line + unauthed hint
- share.go: runWatchCmd + ctx-accepting runWatchCmdWithCtx (mirrors
  the runShare / runShareWithCtx split for testability)
- watch.go: header note clarifying that runWatch (local preview) and
  runWatchCmd (remote live-share) are deliberately separate paths
- completions: add `watch` to bash + zsh
- README: lead with `gander watch README.md` as the headline example
- man/man1/gander.1: synopsis entry, Watch section, example
@scott
scott force-pushed the feat/65-gander-watch-subcommand branch from e395925 to 568ce41 Compare August 26, 2026 04:42
@scott
scott merged commit 6f66266 into main Aug 26, 2026
1 check 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.

feat: add 'gander watch <file>' subcommand as shorthand for 'gander share --watch'

1 participant