Artifact d23ea737bfe951b12c73666e51876b2a378ce33c90a27198610e0d0aba50eb74:
- File
cli/repo_config.go
— part of check-in
[f5744359d3]
at
2026-04-19 16:30:54
on branch trunk
— Initial open source release
libfossil is a pure-Go implementation of the Fossil SCM, reading and writing the same .fossil SQLite repository format as upstream Fossil.
This is the first public release of code that previously lived in a private repository. The module path is github.com/danmestas/libfossil and the binary is named libfossil to avoid $PATH collisions with upstream fossil.
Included: - Repo lifecycle (create, clone), checkout/checkin, timeline, merge, diff, annotate, shun, tag, branch, bisect, stash, undo/redo - Sync-over-HTTP protocol (client and handler) - Two SQLite drivers: modernc (pure Go, default) and ncruces (wasm-capable) - Observer interfaces (SyncObserver, CheckoutObserver) with an optional OpenTelemetry implementation in observer/otel (separate submodule) - Deterministic simulation testing harness with BUGGIFY fault injection - Kong-based embeddable CLI under cli/ and a standalone binary under cmd/libfossil/ (user: [email protected], size: 1567) [annotate] [blame] [check-ins using]
package cli import "fmt" // RepoConfigCmd groups configuration operations. type RepoConfigCmd struct { Ls RepoConfigLsCmd `cmd:"" help:"List all config entries"` Get RepoConfigGetCmd `cmd:"" help:"Get a config value"` Set RepoConfigSetCmd `cmd:"" help:"Set a config value"` } // RepoConfigLsCmd lists all config entries. type RepoConfigLsCmd struct{} func (c *RepoConfigLsCmd) Run(g *Globals) error { r, err := g.OpenRepo() if err != nil { return err } defer r.Close() db := r.Inner().DB() rows, err := db.Query("SELECT name, value FROM config ORDER BY name") if err != nil { return err } defer rows.Close() for rows.Next() { var name, value string rows.Scan(&name, &value) fmt.Printf("%-20s %s\n", name, value) } return rows.Err() } // RepoConfigGetCmd gets a single config value. type RepoConfigGetCmd struct { Key string `arg:"" help:"Config key to get"` } func (c *RepoConfigGetCmd) Run(g *Globals) error { r, err := g.OpenRepo() if err != nil { return err } defer r.Close() val, err := r.Config(c.Key) if err != nil { return fmt.Errorf("config key %q not found", c.Key) } fmt.Println(val) return nil } // RepoConfigSetCmd sets a config value. type RepoConfigSetCmd struct { Key string `arg:"" help:"Config key"` Value string `arg:"" help:"Config value"` } func (c *RepoConfigSetCmd) Run(g *Globals) error { r, err := g.OpenRepo() if err != nil { return err } defer r.Close() if err := r.SetConfig(c.Key, c.Value); err != nil { return err } fmt.Printf("%s = %s\n", c.Key, c.Value) return nil }