From ac81e470cfecaf8387ff621bd36ced28e56ee3fc Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 27 Oct 2025 10:44:52 -0500 Subject: some working on seperate cache / mode settings --- Makefile | 2 +- argv.go | 5 +++++ build | 3 +++ complete.go | 22 +++++++++++++++++++++- doNormal.go | 18 +++++------------- resources/golang.text | 7 +++++++ 6 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 resources/golang.text diff --git a/Makefile b/Makefile index a39f753..2e739cc 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ BUILDTIME = $(shell date +%s) # make andlabs # try the andlabs gui plugin (uses GTK) default: install - forge + forge --verbose redo: clean forge generate clean diff --git a/argv.go b/argv.go index c7d5eeb..fe8ad2f 100644 --- a/argv.go +++ b/argv.go @@ -10,6 +10,7 @@ package main var argv args type args struct { + Cache *CacheCmd `arg:"subcommand:cache" help:"chose the cache of repos to work with"` Clean *CleanCmd `arg:"subcommand:clean" help:"'git clean' + reset repos to original state"` Commit *CommitCmd `arg:"subcommand:commit" help:"'git commit'"` Gui *EmptyCmd `arg:"subcommand:gui" help:"open the gui"` @@ -115,6 +116,10 @@ type GenerateCmd struct { Strict bool `arg:"--strict" help:"die if any namespaces are missing"` } +type CacheCmd struct { + Filename string `arg:"positional"` +} + type CleanCmd struct { List *EmptyCmd `arg:"subcommand:list" help:"list not clean repos"` } diff --git a/build b/build index a04e4c0..ffcc1e0 100755 --- a/build +++ b/build @@ -6,3 +6,6 @@ cp ../utils/wit-utils/forgeConfig/forgeConfig files/usr/bin/ mkdir -p files/usr/share/bash-completion/completions/ forge --bash > files/usr/share/bash-completion/completions/forge + +mkdir -p files/usr/share/doc/forge +cp resources/gopath.text files/usr/share/doc/forge diff --git a/complete.go b/complete.go index 191cf90..83c00de 100644 --- a/complete.go +++ b/complete.go @@ -103,6 +103,11 @@ func (a args) DoAutoComplete() error { fmt.Fprintf(argvpb.Stderr, "returned from parseFlagsArgv(%v)\n", err) } } + if argvpb.PB.IsMatch("cache") { + matches, _ := matchCacheFiles() + fmt.Fprintf(argvpb.Stdout, matches) + return nil + } if argvpb.PB.IsMatch("mode.--config") { matches, _ := matchModeDirs() fmt.Fprintf(argvpb.Stdout, matches) @@ -116,7 +121,7 @@ func (a args) DoAutoComplete() error { } if argvpb.PB.GetCmd() == "" { // these are base autocomplete strings - matches := []string{"clean", "commit", "merge", "patch", "normal", "pull", "rebuild", "generate", "config"} + matches := []string{"clean", "commit", "merge", "patch", "normal", "pull", "rebuild", "generate", "config", "cache"} matches = append(matches, "show", "add", "fixer", "dev", "verify", "mode", "gui", "whatchanged") matches = append(matches, "--version", "--force", "--all", "--verbose") fmt.Fprintf(argvpb.Stdout, strings.Join(matches, " ")) @@ -144,3 +149,18 @@ func matchModeDirs() (string, error) { // log.Info("glob:", globPattern, "matchdirs:", match) return match, err } + +func matchCacheFiles() (string, error) { + configDir, _ := os.UserCacheDir() + globPattern := filepath.Join(configDir, "forge", "repos*.pb") + files, err := filepath.Glob(globPattern) + match := "all golang homedir" + for _, file := range files { + if config.IsDir(file) { + _, base := filepath.Split(file) + match += base + " " + } + } + // log.Info("glob:", globPattern, "matchdirs:", match) + return match, err +} diff --git a/doNormal.go b/doNormal.go index cf333fd..e8ccd68 100644 --- a/doNormal.go +++ b/doNormal.go @@ -28,20 +28,9 @@ func doNormalAll() (string, error) { var err error me.curpatches = forgepb.NewPatches() - me.curpatches.Filename = env.Get("curpatches") - if me.curpatches.Filename == "" { - panic("config failed. no 'curpatches' set in ~/.config/forge/config.text") - } + me.curpatches.Filename = config.MakeCacheFilename("forge", "curpatches") if err := me.curpatches.Load(); err != nil { - me.curpatches.Save() - me.curpatches.Save() - log.Info(err) panic("no file") - // return - // // THIS IS NEEDED? NOTSURE - me.curpatches = forgepb.NewPatches() - me.curpatches.Filename = env.Get("curpatches") - me.curpatches.Save() } psets := forgepb.NewSets() @@ -62,6 +51,9 @@ func doNormalAll() (string, error) { } func (a *args) DoNormal() (string, error) { + env.Set("modeDir", "jwc") + env.Save() + panic("donormal. yay") return doNormalAttempt() } @@ -273,7 +265,7 @@ func checkNormalRepoState(repo *gitpb.Repo) error { // verify read-only if me.forge.Config.IsReadOnly(repo.GetNamespace()) != repo.GetReadOnly() { repo.ReadOnly = me.forge.Config.IsReadOnly(repo.GetNamespace()) - log.Info("damnit", repo.FullPath) + log.Info("readonly bit wrong", repo.FullPath) err = log.Errorf("readonly bit wrong") } return err diff --git a/resources/golang.text b/resources/golang.text new file mode 100644 index 0000000..34ba92f --- /dev/null +++ b/resources/golang.text @@ -0,0 +1,7 @@ +uuid: "1941cd4f-1cfd-4bf6-aa75-c2c391907e81" +version: "v0.0.48 go.wit.com/lib/protobuf/forgepb" +ForgeConfigs: { + namespace: "go.wit.com" + writable: true + directory: true +} -- cgit v1.2.3