From 38c0ec7caadcfa51baf364b76cda14e2c656d0ee Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 6 Jan 2025 20:57:52 -0600 Subject: [PATCH] move config handling here --- doConfig.go | 28 ++++++++++++++++++++++++++++ findRepos.go => find.go | 0 main.go | 31 +++++++------------------------ 3 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 doConfig.go rename findRepos.go => find.go (100%) diff --git a/doConfig.go b/doConfig.go new file mode 100644 index 0000000..52581c8 --- /dev/null +++ b/doConfig.go @@ -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("") +} diff --git a/findRepos.go b/find.go similarity index 100% rename from findRepos.go rename to find.go diff --git a/main.go b/main.go index d8e0ef0..d168b30 100644 --- a/main.go +++ b/main.go @@ -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