Artifact 7872a4ba886e258b77849614af7d32b443db99395fb6f2d362488aebf73edd8e:
- File
cmd/libfossil/main.go
— part of check-in
[beed361c03]
at
2026-10-19 20:17:37
on branch feat/cli-snapshot
— feat(cli): checkout-free snapshot, per-path log, cat --at and diff --json
repo snapshot commits one file's bytes onto trunk with no checkout, a no-op when they equal the tip. repo log --path lists the check-ins that changed a path, repo cat --at reads a file as a version holds it, and repo diff --json A B [PATH] diffs two versions. Exit 2 means not found. A snapshot re-checks the check-in stamp inside its write transaction and retries, so concurrent processes build one linear trunk.
Tracked in #451 (user: [email protected], size: 1056) [annotate] [blame] [check-ins using]
package main import ( "errors" "fmt" "os" "github.com/alecthomas/kong" "github.com/danmestas/go-libfossil/cli" ) // CLI is the top-level command structure. // // Version is deliberately a subcommand only, not also a global --version // flag: `repo extract` already has its own --version flag (the source // version to extract from), and kong's global flags are visible in every // subcommand's context, so a root-level --version would collide with it. // Renaming that existing, unrelated flag to make room isn't part of this // change. type CLI struct { cli.Globals Repo cli.RepoCmd `cmd:"" help:"Repository operations"` Version cli.VersionCmd `cmd:"" help:"Print version information"` } func main() { var c CLI ctx := kong.Parse(&c, kong.Name("libfossil"), kong.Description("Fossil-compatible repository tool (pure Go)"), kong.UsageOnError(), ) err := ctx.Run(&c.Globals) var exit *cli.ExitError if errors.As(err, &exit) { fmt.Fprintf(os.Stderr, "libfossil: %v\n", exit) os.Exit(exit.Code) } ctx.FatalIfErrorf(err) }