diff --git a/cmd/africastalking/main.go b/cmd/africastalking/main.go index 942c4ad..1d24358 100644 --- a/cmd/africastalking/main.go +++ b/cmd/africastalking/main.go @@ -44,11 +44,13 @@ func main() { var err error var gettextDir string var langs args.LangVar + var resourceDir string flag.BoolVar(&engineDebug, "d", false, "use engine debug output") flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)") - flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string") flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string") + flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory") + flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.") flag.StringVar(override.StateConn, "state", "?", "state store connection string") flag.UintVar(&size, "s", 160, "max size of output") flag.StringVar(&host, "h", config.Host(), "http host") @@ -57,6 +59,10 @@ func main() { flag.Var(&langs, "language", "add symbol resolution for language") flag.Parse() + if resourceDir != "" { + *override.ResourceConn = resourceDir + override.ResourceConnMode = storage.DBMODE_TEXT + } config.Apply(override) conns, err := config.GetConns() if err != nil { diff --git a/cmd/async/main.go b/cmd/async/main.go index 91bd3f1..9feac12 100644 --- a/cmd/async/main.go +++ b/cmd/async/main.go @@ -53,10 +53,12 @@ func main() { var err error var gettextDir string var langs args.LangVar + var resourceDir string flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)") - flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string") + flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory") + flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.") flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string") flag.StringVar(override.StateConn, "state", "?", "state store connection string") @@ -68,6 +70,10 @@ func main() { flag.Var(&langs, "language", "add symbol resolution for language") flag.Parse() + if resourceDir != "" { + *override.ResourceConn = resourceDir + override.ResourceConnMode = storage.DBMODE_TEXT + } config.Apply(override) conns, err := config.GetConns() if err != nil { diff --git a/cmd/http/main.go b/cmd/http/main.go index 63a510a..ec4b95b 100644 --- a/cmd/http/main.go +++ b/cmd/http/main.go @@ -43,10 +43,12 @@ func main() { var err error var gettextDir string var langs args.LangVar + var resourceDir string flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)") - flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string") flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string") + flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory") + flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.") flag.StringVar(override.StateConn, "state", "?", "state store connection string") flag.BoolVar(&engineDebug, "d", false, "use engine debug output") @@ -57,6 +59,10 @@ func main() { flag.Var(&langs, "language", "add symbol resolution for language") flag.Parse() + if resourceDir != "" { + *override.ResourceConn = resourceDir + override.ResourceConnMode = storage.DBMODE_TEXT + } config.Apply(override) conns, err := config.GetConns() if err != nil { diff --git a/cmd/main.go b/cmd/main.go index 08eb2f1..c0354a7 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -36,10 +36,12 @@ func main() { var err error var gettextDir string var langs args.LangVar + var resourceDir string flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)") - flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string") + flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory") + flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.") flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string") flag.StringVar(override.StateConn, "state", "?", "state store connection string") flag.BoolVar(&engineDebug, "d", false, "use engine debug output") @@ -48,6 +50,10 @@ func main() { flag.Var(&langs, "language", "add symbol resolution for language") flag.Parse() + if resourceDir != "" { + *override.ResourceConn = resourceDir + override.ResourceConnMode = storage.DBMODE_TEXT + } config.Apply(override) conns, err := config.GetConns() if err != nil { diff --git a/config/args.go b/config/args.go index 4ba4bc8..a9f69e5 100644 --- a/config/args.go +++ b/config/args.go @@ -4,19 +4,12 @@ import ( viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config" ) -type Override struct { - DbConn *string - StateConn *string - ResourceConn *string - UserConn *string -} - -func NewOverride() *Override { +func NewOverride() *viseconfig.Override { var a string var b string var c string var d string - o := &Override{ + o := &viseconfig.Override{ DbConn: &a, StateConn: &b, ResourceConn: &c, @@ -25,7 +18,7 @@ func NewOverride() *Override { return o } -func Apply(o *Override) error { - viseconfig.ApplyConn(o.DbConn, o.StateConn, o.ResourceConn, o.UserConn) +func Apply(o *viseconfig.Override) error { + viseconfig.ApplyConn(o) return nil } diff --git a/devtools/admin/main.go b/devtools/admin/main.go index 5e408c4..4e93ce8 100644 --- a/devtools/admin/main.go +++ b/devtools/admin/main.go @@ -23,17 +23,24 @@ var ( func main() { config.LoadConfig() + override := config.NewOverride() var sessionId string - var override config.Override + var resourceDir string flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)") - flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string") + flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory") + flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.") + flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string") flag.StringVar(override.StateConn, "state", "?", "state store connection string") flag.Parse() - config.Apply(&override) + if resourceDir != "" { + *override.ResourceConn = resourceDir + override.ResourceConnMode = storage.DBMODE_TEXT + } + config.Apply(override) conns, err := config.GetConns() if err != nil { fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err) diff --git a/devtools/store/dump/main.go b/devtools/store/dump/main.go index a748cd0..f58efce 100644 --- a/devtools/store/dump/main.go +++ b/devtools/store/dump/main.go @@ -32,22 +32,28 @@ func formatItem(k []byte, v []byte, sessionId string) (string, error) { func main() { config.LoadConfig() - var override config.Override + override := config.NewOverride() var sessionId string var database string var engineDebug bool var err error var first bool + var resourceDir string flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)") - flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string") + flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory") + flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.") flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string") flag.StringVar(override.StateConn, "state", "?", "state store connection string") flag.BoolVar(&engineDebug, "d", false, "use engine debug output") flag.Parse() - config.Apply(&override) + if resourceDir != "" { + *override.ResourceConn = resourceDir + override.ResourceConnMode = storage.DBMODE_TEXT + } + config.Apply(override) conns, err := config.GetConns() if err != nil { fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err) diff --git a/go.mod b/go.mod index 33ce1b6..810b3ab 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9 git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805 - git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250121134912-f7d31e4e8162 + git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122093711-8530c450741a git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84 github.com/alecthomas/assert/v2 v2.2.2 github.com/gofrs/uuid v4.4.0+incompatible diff --git a/go.sum b/go.sum index 4de0fe6..f690755 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60= git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805 h1:deGnqf4YCsbxhXgjFEjYjTUCvciLEmI26T9IysRsQXY= git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805/go.mod h1:9bc3d//Qqm11hz7GYRdQc1Uan+0GJIOpvRBbv8cHMu8= -git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250121134912-f7d31e4e8162 h1:NaPbgGQ1Nb+yYF+Qj1LSagpjYeDcSXST8iZwONg4afY= -git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250121134912-f7d31e4e8162/go.mod h1:pjKp9L/ZsWW3kMB0UoIl1yv9TBIuU33mn9Aghxp7vGk= +git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122093711-8530c450741a h1:g0epqAJvHdOvzdGNfH0ZmZ6QKsbcybOroLnYi78ZnDo= +git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122093711-8530c450741a/go.mod h1:pjKp9L/ZsWW3kMB0UoIl1yv9TBIuU33mn9Aghxp7vGk= git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84 h1:VoBmqsjlRdz+IPbtKsAkc1IrMepjR+QlesZT31Jokrk= git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84/go.mod h1:DpibtYpnT3nG4Kn556hRAkdu4+CtiI/6MbnQHal51mQ= github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=