diff options
| author | Jeff Carr <[email protected]> | 2025-10-27 18:38:14 -0500 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-27 18:38:14 -0500 | 
| commit | e5cd179c5887de8287fc0faed31838db06cca27e (patch) | |
| tree | fdb87e69282d52be3653f61b5a88a072b0db5e56 | |
| parent | 16ec641ec1dcc2192374ef2e3f76f192f64d329d (diff) | |
getting help back slowly
| -rw-r--r-- | argv.go | 6 | ||||
| -rw-r--r-- | complete.go | 34 | ||||
| -rw-r--r-- | doClean.go | 73 | 
3 files changed, 50 insertions, 63 deletions
@@ -11,7 +11,7 @@ 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"` +	Clean       *EmptyCmd    `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"`  	Config      *ConfigCmd   `arg:"subcommand:config"        help:"show your .config/forge/ settings"` @@ -120,10 +120,6 @@ type CacheCmd struct {  	Filename string `arg:"positional"`  } -type CleanCmd struct { -	List *EmptyCmd `arg:"subcommand:list"             help:"list not clean repos"` -} -  type CleanDevelCmd struct {  	Force bool `arg:"--force"                         help:"try to strong arm things"`  } diff --git a/complete.go b/complete.go index 83c00de..bbc214e 100644 --- a/complete.go +++ b/complete.go @@ -88,20 +88,36 @@ func (args) Examples() string {  	return out  } -// matches -func (c CleanCmd) Match(partial string) []string { -	// return repos here -	return []string{"go.wit.com/apps/forge", "go.wit.com/apps/virtigo"} -} -  // sends the strings to bash or zsh that will be your options  func (a args) DoAutoComplete() error {  	var err error  	if me.pp == nil {  		me.pp, err = arg.ParseFlagsArgv(&argv)  		if err != nil { -			fmt.Fprintf(argvpb.Stderr, "returned from parseFlagsArgv(%v)\n", err) +			fmt.Fprintf(argvpb.Stddbg, "returned from parseFlagsArgv(%v)\n", err) +		} +	} +	if argvpb.PB.HelpCounter > 3 { +		argvpb.SetDebug(true) +		argvpb.PB.HelpCounter = 0 +		if argvpb.Len() == 0 { +			fmt.Fprintf(argvpb.Stddbg, "len(PB.Real)=(%d)\n", len(argvpb.PB.Real)) +			me.pp.WriteHelp(argvpb.Stderr) +			fmt.Fprintf(argvpb.Stddbg, "WriteHelp() (%v)\n", "fricking got here") +			fmt.Fprintf(argvpb.Stddbg, "WriteHelp() (%v)\n", "fricking got here") +			fmt.Fprintf(argvpb.Stddbg, "WriteHelp() (%v)\n", "fricking got here") +			return nil +		} else { +			fmt.Fprintf(argvpb.Stddbg, "WriteHelp() damnit len(%v) (%v)\n", len(argvpb.PB.Real), argvpb.PB.Real) +			fmt.Fprintf(argvpb.Stddbg, "WriteHelp() damnit len(%v) (%v)\n", len(argvpb.PB.Real), argvpb.PB.Real) +			fmt.Fprintf(argvpb.Stddbg, "WriteHelp() damnit len(%v) (%v)\n", len(argvpb.PB.Real), argvpb.PB.Real)  		} +		err = me.pp.WriteHelpForAutocomplete("", argvpb.PB.Real...) +		if err != nil { +			fmt.Fprintf(argvpb.Stddbg, "returned from WriteHelpForAutocomplete() pb.Real(%v)\n", argvpb.PB.Real) +			fmt.Fprintf(argvpb.Stddbg, "returned from WriteHelpForAutocomplete(%v)\n", err) +		} +		return nil  	}  	if argvpb.PB.IsMatch("cache") {  		matches, _ := matchCacheFiles() @@ -129,8 +145,8 @@ func (a args) DoAutoComplete() error {  	}  	err = me.pp.WriteHelpForAutocomplete(argvpb.PB.Partial, argvpb.PB.Real...)  	if err != nil { -		fmt.Fprintf(argvpb.Stderr, "returned from WriteHelpForAutocomplete() pb.Real(%v)\n", argvpb.PB.Real) -		fmt.Fprintf(argvpb.Stderr, "returned from WriteHelpForAutocomplete(%v)\n", err) +		fmt.Fprintf(argvpb.Stddbg, "returned from WriteHelpForAutocomplete() pb.Real(%v)\n", argvpb.PB.Real) +		fmt.Fprintf(argvpb.Stddbg, "returned from WriteHelpForAutocomplete(%v)\n", err)  	}  	return err  } @@ -8,8 +8,8 @@ import (  	"fmt"  	"path/filepath" +	"go.wit.com/lib/env"  	"go.wit.com/lib/fhelp" -	"go.wit.com/lib/protobuf/forgepb"  	"go.wit.com/lib/protobuf/gitpb"  	"go.wit.com/log"  ) @@ -42,19 +42,16 @@ func doResetRepo(repo *gitpb.Repo) error {  func doClean() (string, error) {  	var s string  	var err error - -	if argv.Clean.List != nil { -		s, err = doCleanList() -		return s, err -	} +	var allerr error  	if me.forge.IsModeNormal() {  		s := fmt.Sprintf("Reset all (%d) git repos to the original state (non-destructive)?", me.forge.Repos.Len())  		if !fhelp.QuestionUser(s) {  			s, err = doModeMaster() +			allerr = errors.Join(allerr, err)  		}  	} -	me.forge.SetMode(forgepb.ForgeMode_CLEAN) +	me.forge.SetCleaningMode()  	// fix this to work, then delete all the other options for "forge clean'  	if err := me.forge.DoAllCheckoutMaster(); err != nil { @@ -62,56 +59,34 @@ func doClean() (string, error) {  	}  	me.forge.RescanRepos() // looks for new dirs, checks existing repos for changes +	notclean := gitpb.NewRepos()  	all := me.forge.Repos.SortByFullPath()  	for all.Scan() {  		repo := all.Next() -		doResetRepo(repo) -	} - -	me.forge.RescanRepos() // looks for new dirs, checks existing repos for changes -	return "all repos should be clean", nil -} - -func doCleanList() (string, error) { -	found := gitpb.NewRepos() - -	total := 0 -	// find all repos that aren't "clean" -	for repo := range me.forge.Repos.IterByFullPath() { -		total += 1 - -		// find repos not on master branch -		if repo.GetCurrentBranchName() != repo.GetMasterBranchName() { -			found.AppendByFullPath(repo) -			continue -		} - -		// find dirty repos -		if repo.IsDirty() { -			found.AppendByFullPath(repo) -			continue -		} - -		// find repos that still have a local user branch -		if repo.IsLocalBranch(repo.GetUserBranchName()) { -			found.AppendByFullPath(repo) -			continue +		err := doResetRepo(repo) +		if err != nil { +			newr := notclean.Clone(repo) +			newr.State = fmt.Sprintf("%v", err) +			allerr = errors.Join(allerr, err)  		} +	} -		// find repos that still have a local devel branch -		if repo.IsLocalBranch(repo.GetDevelBranchName()) { -			found.AppendByFullPath(repo) -			continue +	if notclean.Len() > 0 { +		if env.True("--force") { +			// try to force the issue +			for r := range notclean.IterAll() { +				log.Info("FORCE THE ISSUE", r.FullPath) +			} +		} else { +			log.Info("NOT FORCEING THE ISSUE")  		} +		footer := me.forge.NormalCheckTB(notclean) +		s = fmt.Sprintf("(%d) not clean repos %s", notclean.Len(), footer) +		allerr = errors.Join(allerr, errors.New(s)) +		return s, allerr  	} -	var s string -	if found.Len() == 0 { -		s = log.Sprintf("%d repos are not clean", found.Len()) -	} else { -		s = log.Sprintf("All %d repos are clean", me.forge.Repos.Len()) -	} -	return s, nil +	return "all repos are clean", nil  }  func doRepoCleanDevel(repo *gitpb.Repo) error {  | 
