back to a common forge.Init()

This commit is contained in:
Jeff Carr 2025-09-11 04:38:52 -05:00
parent c62f48ec16
commit 15d545f389
1 changed files with 14 additions and 1 deletions

15
init.go
View File

@ -6,6 +6,7 @@ import (
"os"
"time"
"go.wit.com/lib/config"
"go.wit.com/lib/fhelp"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/gitpb"
@ -22,6 +23,18 @@ func Default(opts ...OptionFunc) *Engine {
}
*/
func Init() *Forge {
cfg := new(ForgeConfigs)
err := config.ConfigLoad(cfg, "forge", "forge")
if err != nil {
log.Info("forge has not been configured yet")
log.Info("go install go.wit.com/apps/forge@latest")
os.Exit(-1)
}
f := initFromConfig(cfg)
log.Info("forge.Init() ok len(repos) =", f.Repos.Len())
return f
}
func (f *Forge) InitScan() {
if f.hasFullScan {
// duplicate time checking below. which one to keep?
@ -54,7 +67,7 @@ func (f *Forge) InitScan() {
log.Log(INFO, "update() check took", shell.FormatDuration(time.Since(now)))
}
func InitFromConfig(cfg *ForgeConfigs) *Forge {
func initFromConfig(cfg *ForgeConfigs) *Forge {
f := new(Forge)
f.Config = cfg
if f.configENV() {