package main import ( "os" "go.wit.com/lib/protobuf/forgepb" "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) } } // try to add, then save config and exit if argv.Config.Add != nil { log.Info("going to add a new repo", argv.Config.Add.GoPath) deleteGoPath(me.forge, argv.Config.Add.GoPath) new1 := forgepb.ForgeConfig{ GoPath: argv.Config.Add.GoPath, Writable: argv.Config.Add.Writable, ReadOnly: argv.Config.Add.ReadOnly, Private: argv.Config.Add.Private, Directory: argv.Config.Add.Directory, Favorite: argv.Config.Add.Favorite, Interesting: argv.Config.Add.Interesting, MasterBranchName: argv.Config.Add.Master, DevelBranchName: argv.Config.Add.Devel, UserBranchName: argv.Config.Add.User, } me.forge.Config.Append(&new1) me.forge.ConfigSave() os.Exit(0) } me.forge.ConfigPrintTable() okExit("") } func deleteGoPath(f *forgepb.Forge, gopath string) bool { var deleted bool = false for { if f.Config.DeleteByGoPath(gopath) { log.Info("deleted ok", gopath) deleted = true } else { log.Info("did not delete", gopath) break } } return deleted }