Artifact b501da540abb3a72cc4f47015b4983cc8c41f57624475a87183bb6f02e46fa77:
- File
cli/sync_start.go
— part of check-in
[845d1d229e]
at
2026-04-27 16:36:47
on branch trunk
— cli: extract command tree into reusable package
Move sync, bridge, notify, and doctor commands from cmd/edgesync/ into a new top-level cli/ package. The integration struct in cmd/edgesync/cli.go now imports from EdgeSync/cli (aliased as edgecli) and assembles the binary's command surface.
This mirrors libfossil/cli's pattern — the cli/ package exports embeddable Kong command structs that downstream consumers (e.g. agent-infra) can integrate alongside libfossil/cli.RepoCmd into their own unified CLI.
No behavior change: cmd/edgesync still builds the same binary with the same flags, and the existing notify_test.go end-to-end suite passes unchanged. (user: [email protected], size: 1679) [annotate] [blame] [check-ins using] [more...]
package cli import ( "fmt" "log/slog" "os" "os/signal" "syscall" "time" "github.com/danmestas/EdgeSync/leaf/agent" libfossilcli "github.com/danmestas/libfossil/cli" ) // SyncCmd is the top-level command group for leaf agent sync. type SyncCmd struct { Start SyncStartCmd `cmd:"" help:"Start leaf agent daemon"` Now SyncNowCmd `cmd:"" help:"Trigger immediate sync"` } type SyncStartCmd struct { NATSUrl string `help:"NATS server URL" default:"nats://localhost:4222"` PollInterval time.Duration `help:"Sync poll interval" default:"5s"` Push bool `help:"Enable push" default:"true" negatable:""` Pull bool `help:"Enable pull" default:"true" negatable:""` UV bool `help:"Sync unversioned files" default:"false"` Notify bool `help:"Enable notify messaging (requires notify.fossil next to repo)" default:"false"` } func (c *SyncStartCmd) Run(g *libfossilcli.Globals) error { if g.Repo == "" { return fmt.Errorf("repository required (use -R <path>)") } a, err := agent.New(agent.Config{ RepoPath: g.Repo, NATSUpstream: c.NATSUrl, PollInterval: c.PollInterval, Push: c.Push, Pull: c.Pull, UV: c.UV, NotifyEnabled: c.Notify, }) if err != nil { return fmt.Errorf("agent: %w", err) } if err := a.Start(); err != nil { return fmt.Errorf("start: %w", err) } slog.Info("edgesync sync agent running", "repo", g.Repo, "nats", c.NATSUrl, "poll", c.PollInterval, "notify", c.Notify) sig := make(chan os.Signal, 1) signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM) <-sig slog.Info("shutting down") return a.Stop() }