From a6301163eb96e439fa8a993f072fc913e527112e Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Mon, 23 Sep 2024 09:59:21 +0300 Subject: [PATCH 1/7] use latest commit from go-vise 0.2.0 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 7cceaa6..aabd27b 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.grassecon.net/urdt/ussd go 1.22.6 require ( - git.defalsify.org/vise.git v0.1.0-rc.3.0.20240920144308-b2d2c5f18f38 + git.defalsify.org/vise.git v0.1.0-rc.3.0.20240920215822-39b8e4e6b7a6 github.com/alecthomas/assert/v2 v2.2.2 github.com/peteole/testdata-loader v0.3.0 gopkg.in/leonelquinteros/gotext.v1 v1.3.1 diff --git a/go.sum b/go.sum index 5d235cc..a915f5f 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ git.defalsify.org/vise.git v0.1.0-rc.3.0.20240914163514-577f56f43bea h1:6ZYT+dIj git.defalsify.org/vise.git v0.1.0-rc.3.0.20240914163514-577f56f43bea/go.mod h1:JDguWmcoWBdsnpw7PUjVZAEpdC/ubBmjdUBy3tjP63M= git.defalsify.org/vise.git v0.1.0-rc.3.0.20240920144308-b2d2c5f18f38 h1:4aAZijIcq33ixnZ+U48ckDIkwSfZL3St/CqoXZcC5K8= git.defalsify.org/vise.git v0.1.0-rc.3.0.20240920144308-b2d2c5f18f38/go.mod h1:JDguWmcoWBdsnpw7PUjVZAEpdC/ubBmjdUBy3tjP63M= +git.defalsify.org/vise.git v0.1.0-rc.3.0.20240920215822-39b8e4e6b7a6 h1:vPql8/Ra1P2eRSh52GIj85v6uxbSiKrZaXv5bp4VNgQ= +git.defalsify.org/vise.git v0.1.0-rc.3.0.20240920215822-39b8e4e6b7a6/go.mod h1:JDguWmcoWBdsnpw7PUjVZAEpdC/ubBmjdUBy3tjP63M= github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk= github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= github.com/alecthomas/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g= From f215159725b7878e333565420e6c9521518d24fb Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Mon, 23 Sep 2024 11:38:07 +0300 Subject: [PATCH 2/7] change position of LOAD --- services/registration/transaction_pin.vis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/registration/transaction_pin.vis b/services/registration/transaction_pin.vis index cadbdcf..a0941ed 100644 --- a/services/registration/transaction_pin.vis +++ b/services/registration/transaction_pin.vis @@ -5,8 +5,8 @@ RELOAD get_sender MAP get_sender MOUT back 0 MOUT quit 9 -HALT LOAD authorize_account 6 +HALT RELOAD authorize_account CATCH incorrect_pin flag_incorrect_pin 1 INCMP _ 0 From 66cf90f0442803ed45161cff45f2fee3c35f50bc Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Mon, 23 Sep 2024 14:13:26 +0300 Subject: [PATCH 3/7] LOAD and RELOAD get_amount --- services/registration/transaction_initiated.vis | 2 +- services/registration/transaction_pin | 2 +- services/registration/transaction_pin.vis | 3 ++- services/registration/transaction_pin_swa | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/services/registration/transaction_initiated.vis b/services/registration/transaction_initiated.vis index 3b8b9f6..f8cf19c 100644 --- a/services/registration/transaction_initiated.vis +++ b/services/registration/transaction_initiated.vis @@ -1,7 +1,7 @@ LOAD reset_incorrect 6 CATCH incorrect_pin flag_incorrect_pin 1 CATCH _ flag_account_authorized 0 -LOAD get_amount 10 +RELOAD get_amount MAP get_amount RELOAD get_recipient MAP get_recipient diff --git a/services/registration/transaction_pin b/services/registration/transaction_pin index 7b6bddb..a1b7125 100644 --- a/services/registration/transaction_pin +++ b/services/registration/transaction_pin @@ -1,2 +1,2 @@ -{{.get_recipient}} will receive {{.validate_amount}} from {{.get_sender}} +{{.get_recipient}} will receive {{.get_amount}} from {{.get_sender}} Please enter your PIN to confirm: \ No newline at end of file diff --git a/services/registration/transaction_pin.vis b/services/registration/transaction_pin.vis index a0941ed..0388f0c 100644 --- a/services/registration/transaction_pin.vis +++ b/services/registration/transaction_pin.vis @@ -1,4 +1,5 @@ -MAP validate_amount +RELOAD get_amount +MAP get_amount RELOAD get_recipient MAP get_recipient RELOAD get_sender diff --git a/services/registration/transaction_pin_swa b/services/registration/transaction_pin_swa index 8529f0e..1924166 100644 --- a/services/registration/transaction_pin_swa +++ b/services/registration/transaction_pin_swa @@ -1,2 +1,2 @@ -{{.get_recipient}} atapokea {{.validate_amount}} kutoka kwa {{.get_sender}} +{{.get_recipient}} atapokea {{.get_amount}} kutoka kwa {{.get_sender}} Tafadhali weka PIN yako kudhibitisha: \ No newline at end of file From 909d1f3409aba6e645b310db709998afc76b02ca Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Mon, 23 Sep 2024 14:16:01 +0300 Subject: [PATCH 4/7] change position of LOAD function --- services/registration/amount.vis | 1 + services/registration/change_language.vis | 1 - services/registration/main.vis | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/services/registration/amount.vis b/services/registration/amount.vis index 9b2970a..b491fab 100644 --- a/services/registration/amount.vis +++ b/services/registration/amount.vis @@ -9,4 +9,5 @@ CATCH invalid_amount flag_invalid_amount 1 INCMP _ 0 LOAD get_recipient 12 LOAD get_sender 64 +LOAD get_amount 12 INCMP transaction_pin * diff --git a/services/registration/change_language.vis b/services/registration/change_language.vis index 05ca95b..b33acf1 100644 --- a/services/registration/change_language.vis +++ b/services/registration/change_language.vis @@ -1,4 +1,3 @@ -LOAD reset_account_authorized 0 LOAD reset_incorrect 0 CATCH incorrect_pin flag_incorrect_pin 1 CATCH pin_entry flag_account_authorized 0 diff --git a/services/registration/main.vis b/services/registration/main.vis index d883dca..4e27a79 100644 --- a/services/registration/main.vis +++ b/services/registration/main.vis @@ -1,3 +1,4 @@ +LOAD reset_account_authorized 0 LOAD check_balance 64 RELOAD check_balance MAP check_balance From 8a03b05c904f87a674be3daf4ae7953700d5f5dc Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Mon, 23 Sep 2024 21:20:57 +0300 Subject: [PATCH 5/7] reset the positon of LOAD function --- services/registration/change_language.vis | 1 + services/registration/main.vis | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/services/registration/change_language.vis b/services/registration/change_language.vis index b33acf1..05ca95b 100644 --- a/services/registration/change_language.vis +++ b/services/registration/change_language.vis @@ -1,3 +1,4 @@ +LOAD reset_account_authorized 0 LOAD reset_incorrect 0 CATCH incorrect_pin flag_incorrect_pin 1 CATCH pin_entry flag_account_authorized 0 diff --git a/services/registration/main.vis b/services/registration/main.vis index 4e27a79..d883dca 100644 --- a/services/registration/main.vis +++ b/services/registration/main.vis @@ -1,4 +1,3 @@ -LOAD reset_account_authorized 0 LOAD check_balance 64 RELOAD check_balance MAP check_balance From b8852e1ab34fe6316bf67db8882711d29fa43f45 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Tue, 24 Sep 2024 14:10:10 +0300 Subject: [PATCH 6/7] add engineDebug and stateDebug flags --- cmd/main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index bd3d634..036e6cb 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -23,10 +23,12 @@ func main() { var dbDir string var size uint var sessionId string - var debug bool + var engineDebug bool + var stateDebug bool flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from") - flag.BoolVar(&debug, "d", false, "use engine debug output") + flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output") + flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output") flag.UintVar(&size, "s", 160, "max size of output") flag.Parse() @@ -43,6 +45,10 @@ func main() { FlagCount: uint32(16), } + if stateDebug { + cfg.StateDebug = true + } + resourceDir := scriptDir menuStorageService := storage.NewMenuStorageService(dbDir, resourceDir) @@ -93,7 +99,7 @@ func main() { en := lhs.GetEngine() en = en.WithFirst(hl.Init) - if debug { + if engineDebug { en = en.WithDebug(nil) } From 2643c0c9ffcdaf4077357a5eb84851be70e15634 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Tue, 24 Sep 2024 16:11:22 +0300 Subject: [PATCH 7/7] only have a -d for the engineDebug --- cmd/africastalking/main.go | 8 ++------ cmd/async/main.go | 8 ++------ cmd/http/main.go | 8 ++------ cmd/main.go | 8 +------- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/cmd/africastalking/main.go b/cmd/africastalking/main.go index 6c19aa3..c24c4b1 100644 --- a/cmd/africastalking/main.go +++ b/cmd/africastalking/main.go @@ -69,13 +69,11 @@ func main() { var resourceDir string var size uint var engineDebug bool - var stateDebug bool var host string var port uint flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from") flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir") - flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output") - flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output") + flag.BoolVar(&engineDebug, "d", false, "use engine debug output") flag.UintVar(&size, "s", 160, "max size of output") flag.StringVar(&host, "h", "127.0.0.1", "http host") flag.UintVar(&port, "p", 7123, "http port") @@ -91,9 +89,7 @@ func main() { OutputSize: uint32(size), FlagCount: uint32(16), } - if stateDebug { - cfg.StateDebug = true - } + if engineDebug { cfg.EngineDebug = true } diff --git a/cmd/async/main.go b/cmd/async/main.go index b936538..09236fd 100644 --- a/cmd/async/main.go +++ b/cmd/async/main.go @@ -41,14 +41,12 @@ func main() { var resourceDir string var size uint var engineDebug bool - var stateDebug bool var host string var port uint flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from") flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir") - flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output") - flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output") + flag.BoolVar(&engineDebug, "d", false, "use engine debug output") flag.UintVar(&size, "s", 160, "max size of output") flag.StringVar(&host, "h", "127.0.0.1", "http host") flag.UintVar(&port, "p", 7123, "http port") @@ -64,9 +62,7 @@ func main() { OutputSize: uint32(size), FlagCount: uint32(16), } - if stateDebug { - cfg.StateDebug = true - } + if engineDebug { cfg.EngineDebug = true } diff --git a/cmd/http/main.go b/cmd/http/main.go index 9c24a55..6b868ed 100644 --- a/cmd/http/main.go +++ b/cmd/http/main.go @@ -30,13 +30,11 @@ func main() { var resourceDir string var size uint var engineDebug bool - var stateDebug bool var host string var port uint flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from") flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir") - flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output") - flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output") + flag.BoolVar(&engineDebug, "d", false, "use engine debug output") flag.UintVar(&size, "s", 160, "max size of output") flag.StringVar(&host, "h", "127.0.0.1", "http host") flag.UintVar(&port, "p", 7123, "http port") @@ -52,9 +50,7 @@ func main() { OutputSize: uint32(size), FlagCount: uint32(16), } - if stateDebug { - cfg.StateDebug = true - } + if engineDebug { cfg.EngineDebug = true } diff --git a/cmd/main.go b/cmd/main.go index 036e6cb..9db5e0a 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -24,11 +24,9 @@ func main() { var size uint var sessionId string var engineDebug bool - var stateDebug bool flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from") - flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output") - flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output") + flag.BoolVar(&engineDebug, "d", false, "use engine debug output") flag.UintVar(&size, "s", 160, "max size of output") flag.Parse() @@ -45,10 +43,6 @@ func main() { FlagCount: uint32(16), } - if stateDebug { - cfg.StateDebug = true - } - resourceDir := scriptDir menuStorageService := storage.NewMenuStorageService(dbDir, resourceDir)