common code. add "gui" to open the gui

This commit is contained in:
Jeff Carr 2025-09-08 13:48:06 -05:00
parent 11bf5481c7
commit ce813a3450
4 changed files with 27 additions and 7 deletions

View File

@ -23,6 +23,7 @@ type args struct {
Debug *EmptyCmd `arg:"subcommand:debug" help:"debug forge"`
Dirty *DirtyCmd `arg:"subcommand:dirty" help:"show dirty git repos"`
GitFetch *FindCmd `arg:"subcommand:fetch" help:"run 'git fetch master'"`
Gui *EmptyCmd `arg:"subcommand:gui" help:"open the gui"`
List *FindCmd `arg:"subcommand:list" help:"print a table of the current repos"`
Merge *MergeCmd `arg:"subcommand:merge" help:"merge branches"`
Normal *NormalCmd `arg:"subcommand:normal" help:"set every repo to the default state for software development"`

View File

@ -34,7 +34,7 @@ func doNormal() bool {
if count > 0 {
log.Info("Some repos are not in a 'normal' state. error count =", count)
log.Info("TODO: list the repos here. forge patch repos?")
dumpDirtyRepos()
dumpWorkRepos()
configSave = true
return false
}

View File

@ -51,7 +51,7 @@ func doPatchSubmit() error {
func doPatch() error {
if argv.Patch.Repos != nil {
dumpDirtyRepos()
dumpWorkRepos()
return nil
}
@ -156,11 +156,17 @@ func doPatch() error {
// if nothing, show patches & dirty repos
me.forge.Patchsets.PrintTable()
dumpDirtyRepos()
dumpWorkRepos()
return nil
}
func dumpDirtyRepos() {
// Shows repos that are:
// - git dirty repos
// - repos with 'user' branch patches not in 'devel' branch
// - repos with awaiting master branch verions
//
// return true if any are found
func dumpWorkRepos() bool {
// always run dirty first
me.forge.CheckDirtyQuiet()
@ -169,9 +175,11 @@ func dumpDirtyRepos() {
found := findReposWithPatches()
if found.Len() == 0 {
log.Info("you currently have no repos with patches")
return false
} else {
me.forge.PrintHumanTable(found)
}
return true
}
// returns bad if patches can not be applied

17
main.go
View File

@ -257,9 +257,20 @@ func main() {
// open the gui unless the user performed some other
// basically, if you run just 'forge' it should open the GUI
// if opening the GUI, always check git for dirty repos
me.forge.CheckDirty()
doGui()
if argv.Gui != nil {
// if opening the GUI, always check git for dirty repos
me.forge.CheckDirty()
doGui()
}
// got to the end with nothing to do (?)
if dumpWorkRepos() {
// found some repos at least
} else {
// every repo is in a really clean state. no extra files anywhere
// no dirty repos, no repos that need to be published
// nothing different between user and master branch version. not common
log.Info("All of your git repositories appear to be in perfect shape")
}
okExit("")
}