From 57212b9b5c5705d088446a9830c34973300a5ac3 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 3 Oct 2025 10:04:14 -0500 Subject: add some config examples --- config.go | 55 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 8 deletions(-) (limited to 'config.go') diff --git a/config.go b/config.go index 88142bc..348c053 100644 --- a/config.go +++ b/config.go @@ -30,6 +30,16 @@ func (f *Forge) ConfigSave() error { log.Info("This is not forge") return log.Errorf("Only forge can save the forge config file") } + + // migrate from the old gopath to "namespace" + for fc := range f.Config.IterAll() { + if fc.Namespace != "" { + continue + } + if fc.Namespace != fc.GoPath { + fc.Namespace = fc.GoPath + } + } log.Info("Okay, this is", prep.AppName()) if err := f.Config.ConfigSave(); err != nil { @@ -63,18 +73,23 @@ func (cfg *ForgeConfigs) ConfigSave() error { } func (cfg *ForgeConfigs) DumpENV() { - log.Infof("CfgPB.Filename = %s\n", cfg.Filename) - log.Infof("CfgPB.ReposPB = %s\n", cfg.ReposPB) - log.Infof("CfgPB.ReposDir = %s\n", cfg.ReposDir) - log.Infof("CfgPB.PatchPB = %s\n", cfg.PatchPB) - log.Infof("CfgPB.ForgeURL = %s\n", cfg.ForgeURL) + log.Info("s/DumpENV/DumpPB/") + cfg.DumpPB() +} + +func (cfg *ForgeConfigs) DumpPB() { + log.Infof("Config.Filename = %s\n", cfg.Filename) + log.Infof("Config.ReposPB = %s\n", cfg.ReposPB) + log.Infof("Config.ReposDir = %s\n", cfg.ReposDir) + log.Infof("Config.PatchPB = %s\n", cfg.PatchPB) + log.Infof("Config.ForgeURL = %s\n", cfg.ForgeURL) if cfg.GoWork { - log.Infof("CfgPB.GoWork = %v\n", cfg.GoWork) + log.Infof("Config.GoWork = %v\n", cfg.GoWork) } if cfg.Mode != ForgeMode_UNKNOWN { - log.Infof("CfgPB.Mode = %s\n", cfg.Mode) + log.Infof("Config.Mode = %s\n", cfg.Mode) } - // log.Infof("CfgPB.Hostname=%s\n", cfg.Hostname) + // log.Infof("ConfigCfgPB.Hostname=%s\n", cfg.Hostname) } /* @@ -127,6 +142,7 @@ func loadStdConfig() *ForgeConfigs { cfg.PatchPB = filepath.Join(cfgdir, "patches.pb") cfg.ForgeURL = "http://forge.wit.com/" + cfg.addSampleConfigs() cfg.DumpENV() config.SetChanged("forge", true) if !fhelp.QuestionUser("This is your first time using forge, use these default values?") { @@ -138,3 +154,26 @@ func loadStdConfig() *ForgeConfigs { } return cfg } + +// first time user. add go.wit.com as an example +func (cfg *ForgeConfigs) addSampleConfigs() { + newc := new(ForgeConfig) + newc.GoPath = "go.wit.com" + newc.Writable = true + newc.Directory = true + cfg.Append(newc) + + newc = new(ForgeConfig) + newc.GoPath = "priv.wit.com/corp" + newc.Writable = true + newc.Private = true + newc.Directory = true + cfg.Append(newc) + + newc = new(ForgeConfig) + newc.GoPath = "priv.wit.com/corp" + newc.Writable = true + newc.Private = true + newc.Directory = true + cfg.Append(newc) +} -- cgit v1.2.3