trim Init() code
This commit is contained in:
parent
98467dec72
commit
b231a2144d
|
@ -23,3 +23,20 @@ func (cfg *ForgeConfigs) ConfigSave() error {
|
||||||
func (c *ForgeConfigs) ConfigLoad(fullpath string) error {
|
func (c *ForgeConfigs) ConfigLoad(fullpath string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
76
init.go
76
init.go
|
@ -4,9 +4,10 @@ package forgepb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/fhelp"
|
"go.wit.com/lib/fhelp"
|
||||||
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -21,32 +22,12 @@ func Default(opts ...OptionFunc) *Engine {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
func (f *Forge) InitScan() {
|
||||||
func Init() *Forge {
|
|
||||||
f := InitPB()
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
// f.Machine.InitWit()
|
|
||||||
|
|
||||||
if f.hasFullScan {
|
if f.hasFullScan {
|
||||||
// duplicate time checking below. which one to keep?
|
// duplicate time checking below. which one to keep?
|
||||||
if f.FullScanAge() > time.Minute {
|
if f.FullScanAge() > time.Minute {
|
||||||
log.Log(INFO, "forgepb.Scan() skipping scan. been run a minute ago", f.FullScanAge())
|
log.Log(INFO, "forgepb.Scan() skipping scan. been run a minute ago", f.FullScanAge())
|
||||||
return f
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,9 +52,7 @@ func Init() *Forge {
|
||||||
f.configSave = false
|
f.configSave = false
|
||||||
}
|
}
|
||||||
log.Log(INFO, "update() check took", shell.FormatDuration(time.Since(now)))
|
log.Log(INFO, "update() check took", shell.FormatDuration(time.Since(now)))
|
||||||
return f
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
func InitFromConfig(cfg *ForgeConfigs) *Forge {
|
func InitFromConfig(cfg *ForgeConfigs) *Forge {
|
||||||
f := new(Forge)
|
f := new(Forge)
|
||||||
|
@ -98,30 +77,6 @@ func InitFromConfig(cfg *ForgeConfigs) *Forge {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
func (f *Forge) InitPB() {
|
|
||||||
f.setenv()
|
|
||||||
|
|
||||||
// load the ~/.config/forge/ config
|
|
||||||
f.Config = new(ForgeConfigs)
|
|
||||||
if err := f.Config.ConfigLoad(f.configDir); err != nil {
|
|
||||||
log.Log(WARN, "forgepb.ConfigLoad() failed", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
f.Repos = gitpb.NewRepos()
|
|
||||||
f.Repos.ConfigLoad()
|
|
||||||
if f.Repos.HasFullScan {
|
|
||||||
f.hasFullScan = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// init the Patchsets
|
|
||||||
f.Patchsets = NewPatchsets()
|
|
||||||
|
|
||||||
// todo: play with these / determine good values based on user's machine
|
|
||||||
f.rillX = 10
|
|
||||||
f.rillY = 20
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
func (f *Forge) InitMachine() {
|
func (f *Forge) InitMachine() {
|
||||||
if f.Config.Username == "" {
|
if f.Config.Username == "" {
|
||||||
usr, _ := user.Current()
|
usr, _ := user.Current()
|
||||||
|
@ -130,15 +85,6 @@ func (f *Forge) InitMachine() {
|
||||||
f.hostname, _ = os.Hostname()
|
f.hostname, _ = os.Hostname()
|
||||||
// log.Info(hostname, err)
|
// log.Info(hostname, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// only init's the protobuf. intended to not scan or change anything
|
|
||||||
func InitPB() *Forge {
|
|
||||||
f := new(Forge)
|
|
||||||
f.setenv()
|
|
||||||
f.InitPB()
|
|
||||||
return f
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func (f *Forge) SetConfigSave(b bool) {
|
func (f *Forge) SetConfigSave(b bool) {
|
||||||
|
@ -155,18 +101,6 @@ func (f *Forge) Exit() {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func RawInitPB() *Forge {
|
|
||||||
f := new(Forge)
|
|
||||||
f.RawInitPB()
|
|
||||||
return f
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *Forge) RawInitPB() {
|
|
||||||
f.InitPB()
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// the first thing done is process any ENV settings
|
// the first thing done is process any ENV settings
|
||||||
// try to NOT use the ENV settings anywhere but here
|
// try to NOT use the ENV settings anywhere but here
|
||||||
// all initial ENV settings should be stored in the forge struct
|
// all initial ENV settings should be stored in the forge struct
|
||||||
|
@ -193,6 +127,7 @@ func (f *Forge) setenv() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// if the env vars are set, this is probably not a new user
|
// if the env vars are set, this is probably not a new user
|
||||||
func checkenv() bool {
|
func checkenv() bool {
|
||||||
if os.Getenv("FORGE_CONFIG") != "" {
|
if os.Getenv("FORGE_CONFIG") != "" {
|
||||||
|
@ -215,6 +150,7 @@ func checkenv() bool {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func (f *Forge) GetForgeURL() string {
|
func (f *Forge) GetForgeURL() string {
|
||||||
return f.forgeURL
|
return f.forgeURL
|
||||||
|
|
Loading…
Reference in New Issue