package main import ( "os" "go.wit.com/lib/protobuf/forgepb" "go.wit.com/log" ) // sent via ldflags var VERSION string func main() { var f *forgepb.Forge f = forgepb.Init() if argv.List { f.ConfigPrintTable() /* loop := f.Config.SortByGoPath() // get the list of forge configs for loop.Scan() { r := loop.Next() log.Info("repo:", r.GoPath) } */ os.Exit(0) } // try to delete, then save config and exit if argv.Delete { if deleteGoPath(f, argv.GoPath) { log.Info("deleted", argv.GoPath, "ok") f.ConfigSave() os.Exit(0) } log.Info("deleted", argv.GoPath, "did not exist. did nothing") os.Exit(0) } // try to update, then save config and exit if argv.Update { /* if f.UpdateGoPath(argv.Name, argv.GoPath) { // save updated config file repos.ConfigSave() } */ os.Exit(0) } // try to add, then save config and exit if argv.Add { log.Info("going to add a new repo", argv.GoPath) deleteGoPath(f, argv.GoPath) new1 := forgepb.ForgeConfig{ GoPath: argv.GoPath, Writable: argv.Writable, ReadOnly: argv.ReadOnly, Private: argv.Private, Directory: argv.Directory, Favorite: argv.Favorite, Interesting: argv.Interesting, MasterBranchName: argv.Master, DevelBranchName: argv.Devel, UserBranchName: argv.User, } if f.Config.Append(&new1) { log.Info("added", new1.GoPath, "ok") } else { log.Info("added", new1.GoPath, "failed") os.Exit(-1) } f.ConfigSave() os.Exit(0) } } 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 }