package main import ( "os" "go.wit.com/dev/alexflint/arg" "go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) // sent via -ldflags var VERSION string var BUILDTIME string var pp *arg.Parser var forge *forgepb.Forge var check *gitpb.Repo func main() { log.Info("go-clean version", VERSION, "built on", BUILDTIME) pp = arg.MustParse(&argv) // for very new users or users unfamilar with the command line, this may help them if argv.Repo == "help" || argv.Repo == "?" { pp.WriteHelp(os.Stdout) os.Exit(0) } if argv.Repo == "version" { log.Info(argv.Version()) os.Exit(0) } // load the ~/.config/forge/ config // this lets you configure repos you have read/write access too forge = forgepb.Init() check = forge.Repos.FindByGoPath(argv.Repo) if check == nil { log.Info("need to go-clone", argv.Repo) return } log.Info("already have", argv.Repo) log.Info("go src dir", forge.GetGoSrc()) // re-create go.sum and go.mod check.RedoGoMod() deps := check.GoDeps.SortByGoPath() for deps.Scan() { depRepo := deps.Next() log.Info("check has dep:", depRepo.GoPath) } okExit("skipping build of " + argv.Repo) } func okExit(thing string) { log.Info(thing, "ok") log.Info("Finished clone on", check.GetGoPath(), "ok") os.Exit(0) } func badExit(err error) { log.Info("Total repositories:", forge.Repos.Len()) log.Info("Finished go-clean with error", err, forge.GetGoSrc()) os.Exit(-1) }