feat(cli): add 'gander watch <file>' subcommand as alias for 'share --watch' - #67
Merged
Conversation
…-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
force-pushed
the
feat/65-gander-watch-subcommand
branch
from
August 26, 2026 04:42
e395925 to
568ce41
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gander watch <file.md>as a thin top-level shorthand forgander share <file.md> --watch(the canonical "live-share to gander.md on every save" flow).runWatchCmdinshare.godelegates to the existingrunShareWithCtx(..., ["--watch", file]), so auth, mapping writes, fsnotify + debounce + PUT-to-gandermd, and "Already shared … refreshing in place." are reused unchanged.watch.goclarifies that the localrunWatch(preview path,gander <file> --watch) and the new remoterunWatchCmd(share path,gander watch <file>) are deliberately separate code paths despite sharing thewatchname.watchis listed under the authed block inprintUsageand the unauthed hint now mentions it alongsideshare / remove / list / manage / auth.watchsubcommand.gander watch README.mdas the headline live-share example;gander share --watchis kept as the explicit-flag equivalent.man/man1/gander.1) gains a synopsis entry, a Watch section, and an example. The existingTestManPageExistsAndRenderswas extended to assertgander watchis rendered.Related Issue
Closes #65
Testing
go test ./...— all green, including three new tests:TestWatchCmdEqualsShareWatch— end-to-end:runWatchCmdWithCtxissues the samePOST /api/sharesbody (watch: true), opens the share, thenPUTs updates on save against ahttptest.Server. Parallel toTestShareWatchFlowEndToEnd.TestWatchCmdRequiresAuth— with no token in~/.gander, returnsrequireAuth'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 --helpshows the new authed line andgander watch(with no args) prints the usage error.mandoc -Tlint.Notes
runWatchCmdis paired with arunWatchCmdWithCtxvariant (mirroring the existingrunShare/runShareWithCtxsplit) so tests can cancel via context.POST /api/sharesbody the CLI has been sending; the alias is purely a CLI-side ergonomic.