move config handling here

This commit is contained in:
Jeff Carr 2025-01-06 20:57:52 -06:00
parent 2ffc60a5d4
commit 38c0ec7caa
3 changed files with 35 additions and 24 deletions

28
doConfig.go Normal file
View File

@ -0,0 +1,28 @@
package main
import (
"go.wit.com/log"
)
func doConfig() {
if argv.Config.Delete != "" {
me.forge.DeleteByGoPath(argv.Config.Delete)
me.forge.SetConfigSave(true)
okExit("")
}
if argv.Config.Fix != nil {
log.Info("todo")
okExit("")
}
if argv.Config.Register != "" {
if err := doRegister(argv.Config.Register); err == nil {
okExit("attempting to register " + argv.Config.Register)
} else {
badExit(err)
}
}
me.forge.ConfigPrintTable()
okExit("")
}

31
main.go
View File

@ -51,6 +51,12 @@ func main() {
me.forge = forgepb.Init()
me.found = new(gitpb.Repos)
// first find the repos or gopaths to operate on
if argv.Config != nil {
doConfig()
okExit("")
}
if argv.Checkout != nil {
if argv.Checkout.User != nil {
me.forge.CheckoutUser()
@ -81,30 +87,6 @@ func main() {
okExit("")
}
// first find the repos or gopaths to operate on
if argv.Config != nil {
if argv.Config.Delete != "" {
me.forge.DeleteByGoPath(argv.Config.Delete)
me.forge.SetConfigSave(true)
okExit("")
}
if argv.Config.Fix != nil {
log.Info("todo")
okExit("")
}
if argv.Config.Register != "" {
if err := doRegister(argv.Config.Register); err == nil {
okExit("attempting to register " + argv.Config.Register)
} else {
badExit(err)
}
}
me.forge.ConfigPrintTable()
okExit("")
}
log.Info("found", me.found.Len(), "repos. found", len(me.foundPaths), "paths from .config/forge")
if argv.Dirty != nil {
@ -152,6 +134,7 @@ func main() {
}
}
// todo: redo this logic using forgepb
if configSave {
me.forge.ConfigSave()
configSave = false