Adapt override to non-pointer values

This commit is contained in:
lash 2025-01-24 10:15:37 +00:00
parent 9a094f440f
commit fbaba15776
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
12 changed files with 39 additions and 88 deletions

View File

@ -44,14 +44,12 @@ 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.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.StringVar(&override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
flag.StringVar(&override.UserConn, "userdata", "?", "userdata store connection string")
flag.StringVar(&override.ResourceConn, "resource", "?", "resource data directory")
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")
flag.UintVar(&port, "p", config.Port(), "http port")
@ -59,10 +57,6 @@ 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 {

View File

@ -53,14 +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 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.StringVar(&override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
flag.StringVar(&override.ResourceConn, "resource", "?", "resource data directory")
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.UintVar(&size, "s", 160, "max size of output")
@ -70,10 +68,6 @@ 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 {

View File

@ -43,13 +43,11 @@ 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.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.StringVar(&override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
flag.StringVar(&override.UserConn, "userdata", "?", "userdata store connection string")
flag.StringVar(&override.ResourceConn, "resource", "?", "resource data directory")
flag.StringVar(&override.StateConn, "state", "?", "state store connection string")
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
flag.UintVar(&size, "s", 160, "max size of output")
@ -59,10 +57,6 @@ 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 {

View File

@ -38,10 +38,10 @@ func main() {
var langs args.LangVar
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 data directory")
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
flag.StringVar(override.StateConn, "state", "?", "state store connection string")
flag.StringVar(&override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
flag.StringVar(&override.ResourceConn, "resource", "?", "resource data directory")
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.UintVar(&size, "s", 160, "max size of output")
flag.StringVar(&gettextDir, "gettext", "", "use gettext translations from given directory")

View File

@ -38,10 +38,11 @@ func main() {
var stateDebug bool
var host string
var port uint
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.StateConn, "state", "?", "state store connection 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.StateConn, "state", "?", "state store connection string")
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
flag.UintVar(&size, "s", 160, "max size of output")
flag.StringVar(&host, "h", config.HostSSH(), "socket host")

View File

@ -6,35 +6,15 @@ import (
)
func NewOverride() *viseconfig.Override {
var a string
var b string
var c string
var d string
o := &viseconfig.Override{
DbConn: &a,
StateConn: &b,
StateConnMode: storage.DBMODE_TEXT,
ResourceConn: &c,
ResourceConnMode: storage.DBMODE_TEXT,
UserConn: &d,
UserConnMode: storage.DBMODE_BINARY,
}
return o
}
func Apply(o *viseconfig.Override) error {
if *o.DbConn == "?" {
o.DbConn = nil
}
if *o.ResourceConn == "?" {
o.ResourceConn = nil
}
if *o.UserConn == "?" {
o.UserConn = nil
}
if *o.StateConn == "?" {
o.StateConn = nil
}
viseconfig.ApplyConn(o)
return nil
}

View File

@ -25,21 +25,15 @@ func main() {
override := config.NewOverride()
var sessionId string
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 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.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
flag.StringVar(&override.ResourceConn, "resource", "?", "resource data directory")
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
flag.StringVar(override.StateConn, "state", "?", "state store connection string")
flag.StringVar(&override.UserConn, "userdata", "?", "userdata store connection string")
flag.StringVar(&override.StateConn, "state", "?", "state store connection string")
flag.Parse()
if resourceDir != "" {
*override.ResourceConn = resourceDir
override.ResourceConnMode = storage.DBMODE_TEXT
}
config.Apply(override)
conns, err := config.GetConns()
if err != nil {

View File

@ -38,21 +38,15 @@ func main() {
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 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.StringVar(&override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
flag.StringVar(&override.ResourceConn, "resource", "?", "resource data directory")
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()
if resourceDir != "" {
*override.ResourceConn = resourceDir
override.ResourceConnMode = storage.DBMODE_TEXT
}
config.Apply(override)
conns, err := config.GetConns()
if err != nil {

4
go.mod
View File

@ -5,8 +5,8 @@ go 1.23.4
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.20250122123424-6749c632b0a2
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250123142805-2181388f5bf1
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250124100946-03d19283f6fa
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

8
go.sum
View File

@ -2,10 +2,10 @@ git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9 h1:sPcqXQcywxA8W
git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d h1:5mzLas+jxTUtusOKx4XvU+n2QvrV/mH17MnJRy46siQ=
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.20250122123424-6749c632b0a2 h1:ON77G5K0JNuwPb5JT/hRfF6G6+xstlBQgEIEzWydnhg=
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122123424-6749c632b0a2/go.mod h1:pjKp9L/ZsWW3kMB0UoIl1yv9TBIuU33mn9Aghxp7vGk=
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250123142805-2181388f5bf1 h1:BJHfokTHzrw9QjQ+4s2HmSER0iBPuE7byW5oQC2zLIQ=
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250123142805-2181388f5bf1/go.mod h1:gOn89ipaDcDvmQXRMQYKUqcw/sJcwVOPVt2eC6Geip8=
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250124100946-03d19283f6fa h1:yQLKwby3eD/zNjNw/INU5lGiLuWPEHdsgASwMA4UptE=
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250124100946-03d19283f6fa/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=

View File

@ -16,10 +16,10 @@ func init() {
if err != nil {
panic(err)
}
override.StateConn = &stateDir
override.StateConn = stateDir
userDir, err := os.MkdirTemp("", "sarafu-vise-menutraversal-fs-user-")
if err != nil {
panic(err)
}
override.UserConn = &userDir
override.UserConn = userDir
}

View File

@ -21,7 +21,7 @@ func init() {
if err != nil {
panic(err)
}
override.StateConn = &stateDir
override.StateConn = stateDir
userDir, err := os.MkdirTemp("", "sarafu-vise-menutraversal-gdbm-user-")
if err != nil {
panic(err)
@ -30,5 +30,5 @@ func init() {
if err != nil {
panic(err)
}
override.UserConn = &userDir
override.UserConn = userDir
}