Add faker api option for cli cmd

This commit is contained in:
lash 2025-01-12 19:57:20 +00:00
parent a4a429245d
commit 7a6499adb4
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 15 additions and 5 deletions

View File

@ -14,6 +14,8 @@ import (
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
devremote "git.grassecon.net/grassrootseconomics/sarafu-api/dev"
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
)
@ -25,10 +27,11 @@ var (
)
// TODO: external script automatically generate language handler list from select language vise code OR consider dynamic menu generation script possibility
func main() {
config.LoadConfig()
var accountService remote.AccountService
var fakeDir string
var connStr string
var size uint
var sessionId string
@ -41,6 +44,7 @@ func main() {
flag.StringVar(&resourceDir, "resourcedir", scriptDir, "resource dir")
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
flag.StringVar(&connStr, "c", "", "connection string")
flag.StringVar(&fakeDir, "fakedir", "", "if valid path, enables fake api with fsdb backend")
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")
@ -124,7 +128,13 @@ func main() {
os.Exit(1)
}
accountService := &httpremote.HTTPAccountService{}
if fakeDir != "" {
svc := devremote.NewDevAccountService(ctx, fakeDir).WithAutoVoucher(ctx, "FOO", 42)
svc.AddVoucher(ctx, "BAR")
accountService = svc
} else {
accountService = &httpremote.HTTPAccountService{}
}
hl, err := lhs.GetHandler(accountService)
if err != nil {
fmt.Fprintf(os.Stderr, "get accounts service handler: %v\n", err)

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.23.4
require (
git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d
git.grassecon.net/grassrootseconomics/common v0.0.0-20250112155828-b55686e830fd
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250112155754-6fc27c7a81cf
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250112195514-81d2e3e1e9c9
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250112155457-f13dab9a4505
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250112155731-5718f7d18fbf
github.com/alecthomas/assert/v2 v2.2.2

4
go.sum
View File

@ -2,8 +2,8 @@ git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d h1:bPAOVZOX4frSG
git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
git.grassecon.net/grassrootseconomics/common v0.0.0-20250112155828-b55686e830fd h1:OG20aG/sC5yNaU2/rzoAKYp2f0u4lmGP5/Qax8UQD5c=
git.grassecon.net/grassrootseconomics/common v0.0.0-20250112155828-b55686e830fd/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250112155754-6fc27c7a81cf h1:HpxJbSf8dGJMgSvHusXLUi6TDFpibmaP/yX+SVEtcLk=
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250112155754-6fc27c7a81cf/go.mod h1:SiWT0rbK9QhFpmpAbXOtararIKDmiaAcFLHMCqKibKg=
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250112195514-81d2e3e1e9c9 h1:eP77t9ZpO0UBGq7P5uujXxptOQrRFPs1LHf5Yp2O6b8=
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250112195514-81d2e3e1e9c9/go.mod h1:PEjJnAH5gYcjb4RRevaPCswa5VGGNqHSuyapZvIVR6w=
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250112155457-f13dab9a4505 h1:2cGl8MWGjvOd7XiQiI9guu7N+95Ecpdn7l4M6PI7EiA=
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250112155457-f13dab9a4505/go.mod h1:E6W7ZOa7ZvVr0Bc5ot0LNSwpSPYq4hXlAIvEPy3AJ7U=
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250112155731-5718f7d18fbf h1:u7Za2BxHAA9bOzR3CEOlB7xpYF1Qw6680NPdpzNv0W8=