From f5807d9f3a6c96e70912b61fac17120f412b5782 Mon Sep 17 00:00:00 2001 From: ewy Date: Sun, 17 May 2026 01:37:24 +0200 Subject: * integration tests with a pik target to run them * add abstraction for paths to facilitate unit tests * flesh out completion (--install-completion) * do sync init before stateless modes so list knows more --- main.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 036504c..8b905d8 100644 --- a/main.go +++ b/main.go @@ -29,7 +29,7 @@ import ( // syncInitializers are ran before the initializers. // useful for initializing stuff like paths, preparing directories, and reading the environment var syncInitializers = ComponentList[model.Initializer]{ - paths.Paths, + paths.Component, cache.Init, } @@ -108,6 +108,10 @@ func mode[T any](list ModeMap[T], fire func(mode T) error) *int { func pik() int { pflag.Parse() + syncInitializers.RunSync(func(initializer model.Initializer) error { + return initializer.Init() + }) + code := mode(statelessModes, func(mode func() error) error { return mode() }) @@ -115,10 +119,6 @@ func pik() int { return *code } - syncInitializers.RunSync(func(initializer model.Initializer) error { - return initializer.Init() - }) - initializers.RunAsync(func(initializer model.Initializer) error { return initializer.Init() }) @@ -128,9 +128,9 @@ func pik() int { _, _ = spool.Warn("%v\n", err) return 1 } - locs := crawl.RichLocations(here) - last := locs[len(locs)-1] - root, err := os.OpenRoot(last) + locs := append(crawl.RichLocations(here), paths.System.String()) + root, err := os.OpenRoot("/") + defer root.Close() if root == nil { _, _ = spool.Warn("%v\n", err) return 1 @@ -150,14 +150,14 @@ func pik() int { if len(stateErrors) > 0 { return } - err := cache.Insert(st) + err := cache.MergeAndSave(st) if err != nil { - spool.Warn("%v\n", err) + _, _ = spool.Warn("%v\n", err) } }() } else { - c, err = cache.LoadFile(fs, cache.Path[1:]) + c, err = cache.LoadFile(fs, paths.ContextsFile.String()[1:]) if err != nil { _, _ = spool.Warn("%v\n", err) return 1 -- cgit v1.3.1