From 50c006546cc88138416f88b6fa0b041cf792d24c Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Sat, 28 Dec 2024 13:21:03 +0300 Subject: [PATCH] added code to reset the state and persist it --- devtools/restart_state/main.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/devtools/restart_state/main.go b/devtools/restart_state/main.go index 3068a38..5df34fd 100644 --- a/devtools/restart_state/main.go +++ b/devtools/restart_state/main.go @@ -53,25 +53,24 @@ func main() { os.Exit(1) } - // initialize the persister - - // get the state - - // restart the state - - // persist the state - - // exit - st := pe.GetState() if st == nil { logg.ErrorCtxf(ctx, "state fail in devtool", "state", st) - fmt.Errorf("cannot get state") + fmt.Println("cannot get state") os.Exit(1) } - st.Restart() + fmt.Println("The state:", st) - os.Exit(1) + // set empty Code to allow the menu to run from the top + st.Code = []byte{} + + err = pe.Save(sessionId) + if err != nil { + logg.ErrorCtxf(ctx, "failed to persist the state and cache", "error", err) + os.Exit(1) + } + + os.Exit(0) }