From c7ec0e4077a791fedef4f3a94967adc0daa776f0 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Mon, 28 Oct 2024 22:25:30 -0400 Subject: [PATCH 1/4] chifra config --session --- sdk | 2 +- src/apps/chifra/cmd/config.go | 4 + src/apps/chifra/go.mod | 3 + src/apps/chifra/go.sum | 10 + .../chifra/internal/config/handle_session.go | 14 + src/apps/chifra/internal/config/options.go | 4 + src/apps/chifra/internal/config/output.go | 2 + src/apps/chifra/pkg/types/types_session.go | 417 ++++++++++++++++++ src/apps/chifra/pkg/utils/paths.go | 23 + .../goMaker/templates/cmd-line-options.csv | 3 +- src/dev_tools/sdkFuzzer/config.go | 10 + tests | 2 +- 12 files changed, 491 insertions(+), 3 deletions(-) create mode 100644 src/apps/chifra/internal/config/handle_session.go create mode 100644 src/apps/chifra/pkg/types/types_session.go create mode 100644 src/apps/chifra/pkg/utils/paths.go diff --git a/sdk b/sdk index c0a0407b4f..db33738190 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit c0a0407b4f5c1fa4b479ff5176e6faace3a8a6eb +Subproject commit db3373819077b2e6238146ad843ae0e851238865 diff --git a/src/apps/chifra/cmd/config.go b/src/apps/chifra/cmd/config.go index 6d5da90db5..2ce16619ca 100644 --- a/src/apps/chifra/cmd/config.go +++ b/src/apps/chifra/cmd/config.go @@ -54,6 +54,10 @@ func init() { configCmd.Flags().SortFlags = false configCmd.Flags().BoolVarP(&configPkg.GetOptions().Paths, "paths", "a", false, `show the configuration paths for the system`) + configCmd.Flags().BoolVarP(&configPkg.GetOptions().Session, "session", "s", false, `standin for ui code - no purpose (hidden)`) + if os.Getenv("TEST_MODE") != "true" { + _ = configCmd.Flags().MarkHidden("session") + } globals.InitGlobals("config", configCmd, &configPkg.GetOptions().Globals, capabilities) configCmd.SetUsageTemplate(UsageWithNotes(notesConfig)) diff --git a/src/apps/chifra/go.mod b/src/apps/chifra/go.mod index 31355ecd40..bd82b689c6 100644 --- a/src/apps/chifra/go.mod +++ b/src/apps/chifra/go.mod @@ -15,6 +15,7 @@ require ( github.com/panjf2000/ants/v2 v2.10.0 github.com/pelletier/go-toml/v2 v2.2.2 github.com/spf13/cobra v1.7.0 + github.com/wailsapp/wails/v2 v2.9.2 github.com/wealdtech/go-ens/v3 v3.5.2 golang.org/x/crypto v0.25.0 golang.org/x/term v0.22.0 @@ -46,6 +47,8 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/ipfs/boxo v0.8.0 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect + github.com/leaanthony/slicer v1.6.0 // indirect + github.com/leaanthony/u v1.1.0 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/libp2p/go-flow-metrics v0.1.0 // indirect github.com/libp2p/go-libp2p v0.27.8 // indirect diff --git a/src/apps/chifra/go.sum b/src/apps/chifra/go.sum index 512b4a6108..a2fadae945 100644 --- a/src/apps/chifra/go.sum +++ b/src/apps/chifra/go.sum @@ -439,6 +439,10 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+ github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4FW1e6jwpg= github.com/labstack/echo/v4 v4.5.0/go.mod h1:czIriw4a0C1dFun+ObrXp7ok03xON0N1awStJ6ArI7Y= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= +github.com/leaanthony/slicer v1.6.0 h1:1RFP5uiPJvT93TAHi+ipd3NACobkW53yUiBqZheE/Js= +github.com/leaanthony/slicer v1.6.0/go.mod h1:o/Iz29g7LN0GqH3aMjWAe90381nyZlDNquK+mtH2Fj8= +github.com/leaanthony/u v1.1.0 h1:2n0d2BwPVXSUq5yhe8lJPHdxevE2qK5G99PMStMZMaI= +github.com/leaanthony/u v1.1.0/go.mod h1:9+o6hejoRljvZ3BzdYlVL0JYCwtnAsVuN9pVTQcaRfI= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -451,6 +455,8 @@ github.com/libp2p/go-libp2p v0.27.8/go.mod h1:eCFFtd0s5i/EVKR7+5Ki8bM7qwkNW3TPTT github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= +github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -609,6 +615,8 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM= +github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g= github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= @@ -685,6 +693,8 @@ github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBn github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= +github.com/wailsapp/wails/v2 v2.9.2 h1:Xb5YRTos1w5N7DTMyYegWaGukCP2fIaX9WF21kPPF2k= +github.com/wailsapp/wails/v2 v2.9.2/go.mod h1:uehvlCwJSFcBq7rMCGfk4rxca67QQGsbg5Nm4m9UnBs= github.com/wealdtech/go-ens/v3 v3.5.2 h1:70CAIiG9hcue6Ja5wxWcnCwi5UfmiW5NH1styxpAbgU= github.com/wealdtech/go-ens/v3 v3.5.2/go.mod h1:4qs2EEeTmv538RoB8QjLS9w5N1HSXS253qhLyNEShBs= github.com/wealdtech/go-multicodec v1.4.0 h1:iq5PgxwssxnXGGPTIK1srvt6U5bJwIp7k6kBrudIWxg= diff --git a/src/apps/chifra/internal/config/handle_session.go b/src/apps/chifra/internal/config/handle_session.go new file mode 100644 index 0000000000..e4f56cfce5 --- /dev/null +++ b/src/apps/chifra/internal/config/handle_session.go @@ -0,0 +1,14 @@ +package configPkg + +import ( + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" +) + +// HandleSession returns an empty session +func (opts *ConfigOptions) HandleSession(rCtx *output.RenderCtx) error { + fetchData := func(modelChan chan types.Modeler, errorChan chan error) { + modelChan <- &types.Session{} + } + return output.StreamMany(rCtx, fetchData, opts.Globals.OutputOpts()) +} diff --git a/src/apps/chifra/internal/config/options.go b/src/apps/chifra/internal/config/options.go index b9f5bb16d0..3500b07b47 100644 --- a/src/apps/chifra/internal/config/options.go +++ b/src/apps/chifra/internal/config/options.go @@ -28,6 +28,7 @@ import ( type ConfigOptions struct { Mode string `json:"mode,omitempty"` // Either show or edit the configuration Paths bool `json:"paths,omitempty"` // Show the configuration paths for the system + Session bool `json:"session,omitempty"` // Standin for ui code - no purpose Globals globals.GlobalOptions `json:"globals,omitempty"` // The global options Conn *rpc.Connection `json:"conn,omitempty"` // The connection to the RPC server BadFlag error `json:"badFlag,omitempty"` // An error flag if needed @@ -41,6 +42,7 @@ var defaultConfigOptions = ConfigOptions{} func (opts *ConfigOptions) testLog() { logger.TestLog(len(opts.Mode) > 0, "Mode: ", opts.Mode) logger.TestLog(opts.Paths, "Paths: ", opts.Paths) + logger.TestLog(opts.Session, "Session: ", opts.Session) opts.Conn.TestLog(opts.getCaches()) opts.Globals.TestLog() } @@ -70,6 +72,8 @@ func ConfigFinishParseInternal(w io.Writer, values url.Values) *ConfigOptions { opts.Mode = value[0] case "paths": opts.Paths = true + case "session": + opts.Session = true default: if !copy.Globals.Caps.HasKey(key) { err := validate.Usage("Invalid key ({0}) in {1} route.", key, "config") diff --git a/src/apps/chifra/internal/config/output.go b/src/apps/chifra/internal/config/output.go index 6693f1cfe1..5daa67a29a 100644 --- a/src/apps/chifra/internal/config/output.go +++ b/src/apps/chifra/internal/config/output.go @@ -56,6 +56,8 @@ func (opts *ConfigOptions) ConfigInternal(rCtx *output.RenderCtx) error { // EXISTING_CODE if opts.Paths { err = opts.HandlePaths(rCtx) + } else if opts.Session { + err = opts.HandleSession(rCtx) } else { err = opts.HandleShow(rCtx) } diff --git a/src/apps/chifra/pkg/types/types_session.go b/src/apps/chifra/pkg/types/types_session.go new file mode 100644 index 0000000000..b5a2821f6a --- /dev/null +++ b/src/apps/chifra/pkg/types/types_session.go @@ -0,0 +1,417 @@ +package types + +import ( + "context" + "encoding/json" + + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" + "github.com/wailsapp/wails/v2/pkg/runtime" +) + +// Session stores ephemeral things such as last window position, +// last view, and recent file list. +type Session struct { + LastChain string `json:"lastChain"` + LastFile string `json:"lastFile"` + LastFolder string `json:"lastFolder"` + LastRoute string `json:"lastRoute"` + LastSub map[string]string `json:"lastSub"` + Window Window `json:"window"` + Wizard Wizard `json:"wizard"` + Toggles Toggles `json:"toggles"` +} + +func (s Session) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + +func (s *Session) Model(chain, format string, verbose bool, extraOpts map[string]any) Model { + var model = map[string]any{} + var order = []string{} + + model = map[string]any{ + "lastChain": s.LastChain, + "lastFile": s.LastFile, + "lastFolder": s.LastFolder, + "lastRoute": s.LastRoute, + "window": s.Window, + "wizard": s.Wizard, + "toggles": s.Toggles, + } + order = []string{ + "lastChain", + "lastFile", + "lastFolder", + "lastRoute", + "window", + "wizard", + "toggles", + } + + return Model{model, order} +} + +func (s *Session) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} + +func (s *Session) ShallowCopy() Session { + return *s +} + +const theTitle = "Browse by TrueBlocks" + +var defLayout = Layout{ + Header: true, + Menu: true, + Help: true, + Footer: true, +} + +var defHeader = Headers{ + Project: false, + History: true, + Monitors: false, + Names: false, + Abis: false, + Indexes: false, + Manifests: false, + Status: true, + Settings: true, +} + +var defDaemons = Daemons{ + Freshen: true, +} + +var defaultSession = Session{ + LastChain: "mainnet", + LastFile: "Untitled.tbx", + LastRoute: "/wizard", + LastSub: map[string]string{"/history": "0xf503017d7baf7fbc0fff7492b751025c6a78179b"}, + Window: Window{ + X: 0, + Y: 0, + Width: 0, + Height: 0, + Title: theTitle, + }, + Wizard: Wizard{State: Welcome}, + Toggles: Toggles{ + Layout: defLayout, + Headers: defHeader, + Daemons: defDaemons, + }, +} + +func (s *Session) CleanWindowSize(ctx context.Context) { + if s.Window.Width != 0 && s.Window.Height != 0 { + // already set + return + } + + def := Window{Width: 1024, Height: 768} + defer func() { + if s.Window.Width == 0 || s.Window.Height == 0 { + logger.Info("Fixing", s.Window.String()) + s.Window = def + } + _ = s.Save() + }() + + if screens, err := runtime.ScreenGetAll(ctx); err != nil { + logger.Error("Error getting screens", err) + return + } else { + fullScreen := def + for _, screen := range screens { + if screen.IsCurrent || screen.IsPrimary { + fullScreen.Width = screen.Size.Width + fullScreen.Height = screen.Size.Height + break + } + } + + portions := 12 + wScale := 10 + wPortion := fullScreen.Width / portions + hPortion := fullScreen.Height / portions + s.Window.X = wPortion + s.Window.Y = hPortion + s.Window.Width = wScale * wPortion + s.Window.Height = wScale * hPortion + } +} + +// Save saves the session to the configuration folder. +func (s *Session) Save() error { + if fn, err := utils.GetConfigFn("browse", "session.json"); err != nil { + return err + } else { + if contents, _ := json.MarshalIndent(s, "", " "); len(contents) > 0 { + file.StringToAsciiFile(fn, string(contents)) + } + return nil + } +} + +// Load loads the session from the configuration folder. If the file contains +// data, we return true. False otherwise. +func (s *Session) Load() error { + checkWizard := func() (WizState, string) { + if s.Wizard.State == Okay && s.LastRoute == "/wizard" { + s.LastRoute = "/" + _ = s.Save() + } + return s.Wizard.State, s.LastRoute + } + + if fn, err := utils.GetConfigFn("browse", "session.json"); err == nil { + if contents := file.AsciiFileToString(fn); len(contents) > 0 { + if err := json.Unmarshal([]byte(contents), s); err == nil { + s.Wizard.State, s.LastRoute = checkWizard() + if s.LastChain == "" { + s.LastChain = "mainnet" + } + if s.LastFile == "" { + s.LastFile = "Untitled.tbx" + } + return nil + } + } + } + + // falls through above but returns the default session... + *s = defaultSession + s.Wizard.State, s.LastRoute = checkWizard() + _ = s.Save() + return nil +} + +func (s *Session) SetRoute(route, subRoute string) { + s.LastRoute = route + if len(subRoute) > 0 { + s.LastSub[route] = subRoute + } + _ = s.Save() +} + +type Layout struct { + Header bool `json:"header"` + Menu bool `json:"menu"` + Help bool `json:"help"` + Footer bool `json:"footer"` +} + +type Headers struct { + Project bool `json:"project"` + History bool `json:"history"` + Monitors bool `json:"monitors"` + Names bool `json:"names"` + Abis bool `json:"abis"` + Indexes bool `json:"indexes"` + Manifests bool `json:"manifests"` + Status bool `json:"status"` + Settings bool `json:"settings"` +} + +type Daemons struct { + Freshen bool `json:"freshen"` + Scraper bool `json:"scraper"` + Ipfs bool `json:"ipfs"` +} + +type Toggles struct { + Layout Layout `json:"layout"` + Headers Headers `json:"headers"` + Daemons Daemons `json:"daemons"` +} + +func (t *Toggles) IsOn(which string) bool { + if which == "" { + which = "project" + } + switch which { + case "header": + return t.Layout.Header + case "menu": + return t.Layout.Menu + case "help": + return t.Layout.Help + case "footer": + return t.Layout.Footer + case "project": + return t.Headers.Project + case "history": + return t.Headers.History + case "monitors": + return t.Headers.Monitors + case "names": + return t.Headers.Names + case "abis": + return t.Headers.Abis + case "indexes": + return t.Headers.Indexes + case "manifests": + return t.Headers.Manifests + case "status": + return t.Headers.Status + case "settings": + return t.Headers.Settings + case "freshen": + return t.Daemons.Freshen + case "scraper": + return t.Daemons.Scraper + case "ipfs": + return t.Daemons.Ipfs + } + return false +} + +func (t *Toggles) SetState(which string, onOff bool) { + if which == "" { + which = "project" + } + switch which { + case "header": + t.Layout.Header = onOff + case "menu": + t.Layout.Menu = onOff + case "help": + t.Layout.Help = onOff + case "footer": + t.Layout.Footer = onOff + case "project": + t.Headers.Project = onOff + case "history": + t.Headers.History = onOff + case "monitors": + t.Headers.Monitors = onOff + case "names": + t.Headers.Names = onOff + case "abis": + t.Headers.Abis = onOff + case "indexes": + t.Headers.Indexes = onOff + case "manifests": + t.Headers.Manifests = onOff + case "status": + t.Headers.Status = onOff + case "settings": + t.Headers.Settings = onOff + case "freshen": + t.Daemons.Freshen = onOff + case "scraper": + t.Daemons.Scraper = onOff + case "ipfs": + t.Daemons.Ipfs = onOff + } +} + +// Window stores the last position and title of the window +type Window struct { + X int `json:"x"` + Y int `json:"y"` + Width int `json:"width"` + Height int `json:"height"` + Title string `json:"title"` +} + +func (w *Window) String() string { + bytes, _ := json.Marshal(w) + return string(bytes) +} + +type Wizard struct { + State WizState `json:"state"` +} + +var stateOrder = []WizState{ + Welcome, + TomlOkay, + RpcOkay, + BloomsOkay, + IndexOkay, + Okay, +} + +func (w *Wizard) Step(step Step) { + switch step { + case Reset: + w.State = Welcome + case Previous: + for i := range stateOrder { + if stateOrder[i] == w.State && i > 0 { + w.State = stateOrder[i-1] + break + } + } + case Next: + for i := range stateOrder { + if stateOrder[i] == w.State && i < len(stateOrder)-1 { + w.State = stateOrder[i+1] + break + } + } + case Finish: + w.State = Okay + } +} + +type WizState string + +const ( + Welcome WizState = "welcome" + TomlOkay WizState = "tomlOkay" + RpcOkay WizState = "rpcOkay" + BloomsOkay WizState = "bloomsOkay" + IndexOkay WizState = "indexOkay" + Okay WizState = "okay" +) + +// String returns the string representation of the WizState. +func (s WizState) String() string { + return string(s) +} + +// AllStates - all possible WizStates for the frontend codegen +var AllStates = []struct { + Value WizState `json:"value"` + TSName string `json:"tsName"` +}{ + {Welcome, "WELCOME"}, + {TomlOkay, "TOMLOKAY"}, + {RpcOkay, "RPCOKAY"}, + {BloomsOkay, "BLOOMSOKAY"}, + {IndexOkay, "INDEXOKAY"}, + {Okay, "OKAY"}, +} + +type Step string + +const ( + Reset Step = "Reset" + Previous Step = "Previous" + Next Step = "Next" + Finish Step = "Finish" +) + +// String returns the string representation of the Step. +func (s Step) String() string { + return string(s) +} + +// AllSteps - all possible steps for the frontend codegen +var AllSteps = []struct { + Value Step `json:"value"` + TSName string `json:"tsName"` +}{ + {Reset, "RESET"}, + {Previous, "PREVIOUS"}, + {Next, "NEXT"}, + {Finish, "FINISH"}, +} diff --git a/src/apps/chifra/pkg/utils/paths.go b/src/apps/chifra/pkg/utils/paths.go new file mode 100644 index 0000000000..544ce82639 --- /dev/null +++ b/src/apps/chifra/pkg/utils/paths.go @@ -0,0 +1,23 @@ +package utils + +import ( + "os" + "path/filepath" + + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" +) + +// GetConfigFn returns the user's (OS-specific) configuration folder. If the folder +// is not found, an error is returned. If appDir is not empty, it is appended to +// the configDir and if the resulting folder does not exist, it is created. +func GetConfigFn(appDir, fn string) (string, error) { + if userConfig, err := os.UserConfigDir(); err != nil { + return "", err + } else { + configFolder := filepath.Join(userConfig, "TrueBlocks", appDir) + if !file.FolderExists(configFolder) { + _ = file.EstablishFolder(configFolder) + } + return filepath.Join(configFolder, fn), nil + } +} diff --git a/src/dev_tools/goMaker/templates/cmd-line-options.csv b/src/dev_tools/goMaker/templates/cmd-line-options.csv index a2f73952b8..3528f75575 100644 --- a/src/dev_tools/goMaker/templates/cmd-line-options.csv +++ b/src/dev_tools/goMaker/templates/cmd-line-options.csv @@ -235,8 +235,9 @@ num,folder,group,route,tool,longName,hotKey,def_val,attributes,handler,option_ty 41000,,Admin,,,,,,,,group,,,,,,Control the scraper and build the index # 42000,apps,Admin,config,config,,,,visible|docs,,command,,,Manage config, [flags],default|,Report on and edit the configuration of the TrueBlocks system. -42020,apps,Admin,config,config,mode,,,visible|docs,2,positional,enum[show*|edit],,,,,either show or edit the configuration +42020,apps,Admin,config,config,mode,,,visible|docs,3,positional,enum[show*|edit],,,,,either show or edit the configuration 42030,apps,Admin,config,config,paths,a,,visible|docs,1,switch,,cacheItem,,,,show the configuration paths for the system +42040,apps,Admin,config,config,session,s,,,2,switch,,session,,,,standin for ui code - no purpose # 43000,apps,Admin,status,cacheStatus,,,,visible|docs,,command,,,Get status on caches, [mode...] [flags],default|,Report on the state of the internal binary caches. 43020,apps,Admin,status,cacheStatus,modes,,,visible|docs,2,positional,list,status,,,,the (optional) name of the binary cache to report on, terse otherwise diff --git a/src/dev_tools/sdkFuzzer/config.go b/src/dev_tools/sdkFuzzer/config.go index e718db7b27..eebdc850f2 100644 --- a/src/dev_tools/sdkFuzzer/config.go +++ b/src/dev_tools/sdkFuzzer/config.go @@ -54,6 +54,16 @@ func TestConfig(which, value, fn string, opts *sdk.ConfigOptions) { ReportOkay(fn) } } + case "session": + if session, _, err := opts.ConfigSession(); err != nil { + ReportError(fn, opts, err) + } else { + if err := SaveToFile[types.Session](fn, session); err != nil { + ReportError2(fn, err) + } else { + ReportOkay(fn) + } + } default: ReportError(fn, opts, fmt.Errorf("unknown which: %s", which)) logger.Fatal("Quitting...") diff --git a/tests b/tests index 8a4f49aa8e..b3f07acfde 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit 8a4f49aa8eee0f0b37c8f70292943e23b6ebb4cf +Subproject commit b3f07acfde472b69feb37b5fb3aa8f219ed8affc From da3dcaf0d19381750db0aded3a381ad023979e1c Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Mon, 28 Oct 2024 22:44:23 -0400 Subject: [PATCH 2/4] Linting --- src/apps/chifra/pkg/types/types_session.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/chifra/pkg/types/types_session.go b/src/apps/chifra/pkg/types/types_session.go index b5a2821f6a..432611b483 100644 --- a/src/apps/chifra/pkg/types/types_session.go +++ b/src/apps/chifra/pkg/types/types_session.go @@ -153,7 +153,7 @@ func (s *Session) Save() error { return err } else { if contents, _ := json.MarshalIndent(s, "", " "); len(contents) > 0 { - file.StringToAsciiFile(fn, string(contents)) + _ = file.StringToAsciiFile(fn, string(contents)) } return nil } From b4408a55989be3d2b613379dd320530701c5157b Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Mon, 28 Oct 2024 22:51:33 -0400 Subject: [PATCH 3/4] Use wails 2.8.2 --- src/apps/chifra/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/chifra/go.mod b/src/apps/chifra/go.mod index bd82b689c6..ed6ca75006 100644 --- a/src/apps/chifra/go.mod +++ b/src/apps/chifra/go.mod @@ -15,7 +15,7 @@ require ( github.com/panjf2000/ants/v2 v2.10.0 github.com/pelletier/go-toml/v2 v2.2.2 github.com/spf13/cobra v1.7.0 - github.com/wailsapp/wails/v2 v2.9.2 + github.com/wailsapp/wails/v2 v2.8.2 github.com/wealdtech/go-ens/v3 v3.5.2 golang.org/x/crypto v0.25.0 golang.org/x/term v0.22.0 From e080e4901d556fec6e1e607e712220b782684bdc Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Mon, 28 Oct 2024 23:22:45 -0400 Subject: [PATCH 4/4] WizStep --- src/apps/chifra/pkg/types/types_session.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/apps/chifra/pkg/types/types_session.go b/src/apps/chifra/pkg/types/types_session.go index 432611b483..4de3c3b808 100644 --- a/src/apps/chifra/pkg/types/types_session.go +++ b/src/apps/chifra/pkg/types/types_session.go @@ -339,7 +339,7 @@ var stateOrder = []WizState{ Okay, } -func (w *Wizard) Step(step Step) { +func (w *Wizard) Step(step WizStep) { switch step { case Reset: w.State = Welcome @@ -391,24 +391,24 @@ var AllStates = []struct { {Okay, "OKAY"}, } -type Step string +type WizStep string const ( - Reset Step = "Reset" - Previous Step = "Previous" - Next Step = "Next" - Finish Step = "Finish" + Reset WizStep = "Reset" + Previous WizStep = "Previous" + Next WizStep = "Next" + Finish WizStep = "Finish" ) // String returns the string representation of the Step. -func (s Step) String() string { +func (s WizStep) String() string { return string(s) } // AllSteps - all possible steps for the frontend codegen var AllSteps = []struct { - Value Step `json:"value"` - TSName string `json:"tsName"` + Value WizStep `json:"value"` + TSName string `json:"tsName"` }{ {Reset, "RESET"}, {Previous, "PREVIOUS"},