diff options
Diffstat (limited to 'config.go')
| -rw-r--r-- | config.go | 58 |
1 files changed, 58 insertions, 0 deletions
@@ -3,6 +3,8 @@ package forgepb import ( + "os" + "go.wit.com/lib/config" "go.wit.com/lib/gui/prep" "go.wit.com/log" @@ -32,3 +34,59 @@ func (f *Forge) ConfigSave() error { } return err } + +// functions to import and export the protobuf +// data to and from config files + +// write to ~/.config/forge/ +func (cfg *ForgeConfigs) ConfigSave() error { + var header string + header += "\n" + header += "# the forge config file\n" + header += "# You can customize things like:\n" + header += "#\n" + header += "# * which repos you have write access to\n" + header += "# * custom branch names for 'master', 'devel' and 'user'\n" + header += "# * 'favorites' so you can remember which things you like\n" + header += "# * sometimes protobuf TEXT can fail so as a backup this also creates a .json file\n" + header += "#\n" + header += "\n" + return config.ConfigSaveWithHeader(cfg, header) +} + +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.PatchDir = %s\n", cfg.PatchDir) + log.Infof("CfgPB.ForgeURL = %s\n", cfg.ForgeURL) + if cfg.GoWork { + log.Infof("CfgPB.GoWork = %v\n", cfg.GoWork) + } + log.Infof("CfgPB.Mode = %s\n", cfg.Mode) + // log.Infof("CfgPB.Hostname=%s\n", cfg.Hostname) + + if cfg.ReposPB != os.Getenv("FORGE_REPOSPB") { + log.Infof("CfgPB file problem: cfg.ReposPB=%s != FORGE_REPOSPB=%s\n", cfg.ReposPB, os.Getenv("FORGE_REPOSPB")) + } +} + +/* + if f.Config.Username == "" { + usr, _ := user.Current() + f.Config.Username = usr.Username + f.SetConfigSave(true) + } + + if f.Config.Xterm == "" { + f.Config.Xterm = "xterm" + f.Config.XtermArgv = append(f.Config.XtermArgv, "-bg") + f.Config.XtermArgv = append(f.Config.XtermArgv, "black") + f.Config.XtermArgv = append(f.Config.XtermArgv, "-fg") + f.Config.XtermArgv = append(f.Config.XtermArgv, "white") + f.SetConfigSave(true) + } +*/ + +func (cfg *ForgeConfigs) InitDefaults() { +} |
