diff options
| author | Jeff Carr <[email protected]> | 2025-10-28 08:40:26 -0500 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-28 08:40:26 -0500 | 
| commit | 10064774935efffdfda80adc68d06cb1b1fd01d8 (patch) | |
| tree | e3e39e2bf1afb15b8d3ba662d392fc14a27fed4d | |
| parent | 0e83fccb13f0c7d84fe6db01565d5c6a876d7320 (diff) | |
rearrange now that argv is working
| -rw-r--r-- | argv.go | 33 | ||||
| -rw-r--r-- | doFix.go | 12 | ||||
| -rw-r--r-- | doShow.go | 13 | ||||
| -rw-r--r-- | main.go | 6 | ||||
| -rw-r--r-- | subCommand.go | 6 | 
5 files changed, 29 insertions, 41 deletions
@@ -10,23 +10,22 @@ package main  var argv args  type args struct { -	Cache       *CacheCmd    `arg:"subcommand:cache"                     help:"chose the cache of repos to work with"` +	Rebuild     *RebuildCmd  `arg:"subcommand:rebuild"                   help:"download all the forge sources and rebuild forge"` +	Generate    *GenerateCmd `arg:"subcommand:generate"                  help:"helps run autogenpb in repos with .proto files"` +	Show        *ShowCmd     `arg:"subcommand:show"                      help:"show tables"`  	Clean       *EmptyCmd    `arg:"subcommand:clean"                     help:"'git clean' + reset repos to original state"`  	Commit      *CommitCmd   `arg:"subcommand:commit"                    help:"'git commit'"` -	Config      *ConfigCmd   `arg:"subcommand:config"        help:"show your .config/forge/ settings"`  	Merge       *MergeCmd    `arg:"subcommand:merge"                     help:"merge branches"` -	Normal      *EmptyCmd    `arg:"subcommand:normal"                    help:"shortcut to 'forge mode normal'"` -	Mode        *ModeCmd     `arg:"subcommand:mode"                      help:"sets the mode (hacking, merging, publishing)"` -	Patch       *PatchCmd    `arg:"subcommand:patch"                     help:"work with patchsets"`  	Pull        *PullCmd     `arg:"subcommand:pull"                      help:"'git pull'"` -	Show        *ShowCmd     `arg:"subcommand:show"                      help:"print out things"` +	Normal      *EmptyCmd    `arg:"subcommand:normal"                    help:"shortcut to 'forge mode normal'"` +	Patch       *PatchCmd    `arg:"subcommand:patch"                     help:"work with patches"`  	Dev         *DevCmd      `arg:"subcommand:dev"                       help:"features under development"` -	Add         *EmptyCmd    `arg:"subcommand:add"                       help:"Scan directores for git repos"` -	Fixer       *FixCmd      `arg:"subcommand:fixer"                     help:"send in the fixer"` +	Mode        *ModeCmd     `arg:"subcommand:mode"                      help:"sets the mode (hacking, merging, publishing)"` +	Cache       *CacheCmd    `arg:"subcommand:cache"                     help:"chose the cache of repos to work with"`  	Verify      *VerifyCmd   `arg:"subcommand:verify"                    help:"populate stats"` +	Config      *ConfigCmd   `arg:"subcommand:config"        help:"show your .config/forge/ settings"` +	Add         *EmptyCmd    `arg:"subcommand:add"                       help:"Scan directores for git repos"`  	Whatchanged *EmptyCmd    `arg:"subcommand:whatchanged"               ` -	Rebuild     *RebuildCmd  `arg:"subcommand:rebuild"                   help:"download all the forge sources and rebuild forge"` -	Generate    *GenerateCmd `arg:"subcommand:generate"                  help:"helps run autogenpb in repos with .proto files"`  	All         bool         `arg:"--all"                                help:"whatever you are doing, do it all over"`  	Force       bool         `arg:"--force"                              help:"try to strong-arm things"`  	Verbose     bool         `arg:"--verbose"                            help:"show more output than usual"` @@ -40,13 +39,12 @@ type EmptyCmd struct {  type testCmd string  type ShowCmd struct { -	Dirty         *EmptyCmd `arg:"subcommand:dirty"                     help:"show dirty git repos"` -	DirtySave     *EmptyCmd `arg:"subcommand:dirtysave"                 help:"check dirty then save"` -	MasterDefault *EmptyCmd `arg:"subcommand:masterdefault"             help:"run the default behavior for master branches"` -	Mtime         *EmptyCmd `arg:"subcommand:mtime"                     help:"show mtime changes"` -	ENV           *EmptyCmd `arg:"subcommand:ENV"                       help:"show the ENV"` -	Repo          *RepoCmd  `arg:"subcommand:repos"                     help:"print a table of the current repos"` -	Tag           *TagCmd   `arg:"subcommand:tag"                       help:"show git tags"` +	Dirty *EmptyCmd `arg:"subcommand:dirty"                     help:"show dirty git repos"` +	Mtime *EmptyCmd `arg:"subcommand:mtime"                     help:"show mtime changes"` +	ENV   *EmptyCmd `arg:"subcommand:ENV"                       help:"show lib/env"` +	Tag   *TagCmd   `arg:"subcommand:tag"                       help:"show the git tag table"` +	Repo  *RepoCmd  `arg:"subcommand:repos"                     help:"show repos by type. deprecate."` +	// MasterDefault *EmptyCmd `arg:"subcommand:masterdefault"             help:"run the default behavior for master branches"`  }  type RebuildCmd struct { @@ -106,6 +104,7 @@ type CommitCmd struct {  type DevCmd struct {  	Build   *EmptyCmd `arg:"subcommand:build"         help:"build this repo"`  	Install *EmptyCmd `arg:"subcommand:install"       help:"build & install this repo"` +	Fixer   *FixCmd   `arg:"subcommand:fixer"                     help:"send in the fixer"`  	URL     string    `arg:"--connect"                help:"forge url"`  } @@ -16,20 +16,20 @@ func getPorcelain() (string, error) {  }  // is every repo on the devel branch? -func doFix() (string, error) { +func doFix(f *FixCmd) (string, error) {  	var s string  	var err error -	if argv.Fixer.Urls { +	if f.Urls {  		err = doFixUrls()  	} -	if argv.Fixer.Untracked { +	if f.Untracked {  		return doRemoveUntrackedFiles()  	} -	if argv.Fixer.DeleteUser { +	if f.DeleteUser {  		return doDeleteUser()  	} -	if argv.Fixer.Prune { +	if f.Prune {  		// git fetch --prune  		for repo := range me.forge.Repos.IterByNamespace() {  			if me.forge.Config.IsReadOnly(repo.Namespace) { @@ -39,7 +39,7 @@ func doFix() (string, error) {  		}  	} -	if argv.Fixer.Porcelain != nil { +	if f.Porcelain != nil {  		s, err = getPorcelain()  		log.Info("GET PORCELAIN SENT BACK", s, err)  		for repo := range me.forge.Repos.IterByFullPath() { @@ -10,11 +10,6 @@ func doShow() (string, error) {  		s, err := doDirty()  		return s, err  	} -	if argv.Show.DirtySave != nil { -		_, s, err := getDirty() -		me.forge.Repos.Save() -		return s, err -	}  	if argv.Show.Tag != nil {  		doTag() @@ -31,14 +26,6 @@ func doShow() (string, error) {  		return s, err  	} -	if argv.Show.MasterDefault != nil { -		err := defaultBehaviorMaster() -		if err != nil { -			return "has problems", err -		} -		return "default master behavior is ok", nil -	} -  	found := findRepos()  	if showUrls() {  		found.SortNamespace() @@ -30,6 +30,7 @@ func doCoreChecks() {  			// log.Info("things are still normal")  		} else {  			log.Info("doNormalStatus() failed. things are not normal anymore") +			me.forge.SetUserMode()  		}  	} else {  		if !me.forge.IsModeNormal() { @@ -56,7 +57,8 @@ func main() {  	}  	if me.forge.IsModeUnknown() || me.forge.IsModeNewUser() { -		doNewUser() +		panic("always gets here") +		// doNewUser()  	}  	// put things to do every time forge runs here @@ -72,7 +74,7 @@ func main() {  		argvpb.GoodExit(s)  	} -	log.Info("Starting forge with subcommand:", argvpb.GetCmd()) +	log.Info("Starting forge with subcommand:", argvpb.Real())  	s, err = doSubcommand()  	// if the gui starts, it doesn't yet go to the end normally diff --git a/subCommand.go b/subCommand.go index 0a051d2..d64ef5d 100644 --- a/subCommand.go +++ b/subCommand.go @@ -26,10 +26,10 @@ func doSubcommand() (string, error) {  	if argv.Dev != nil {  		s, err = doDev() -	} -	if argv.Fixer != nil { -		s, err = doFix() +		if argv.Dev.Fixer != nil { +			s, err = doFix(argv.Dev.Fixer) +		}  	}  	if argv.Clean != nil {  | 
