package main import ( "go.wit.com/gui" "go.wit.com/log" ) func globalResetOptions(box *gui.Node) { group2 := box.NewGroup("Global Destructive Options") buildOptions := group2.NewGrid("buildOptions", 2, 1) buildOptions.NewLabel("global path reset") // to globally reset paths: // gofmt -w -r "go.wit.com/gui -> go.wit.com/gui/gui" . buildOptions.NewButton("Find", func() { log.Warn("delete every repo marked PERFECT") var newCmds [][]string for repo, _ := range me.allrepos { status := repo.getStatus() if status == "PERFECT" { var line []string line = append(line, "rm", "-rf", "go/src/"+repo.path) newCmds = append(newCmds, line) } } me.script = newCmds doit.Enable() setGitCommands() }) buildOptions.NewLabel("delete PERFECT") buildOptions.NewButton("Find", func() { log.Warn("delete every repo marked PERFECT") var newCmds [][]string for repo, path := range me.allrepos { status := repo.getStatus() if status == "PERFECT" { var line []string line = append(line, "rm", "-rf", "go/src/"+path) newCmds = append(newCmds, line) } } me.script = newCmds doit.Enable() setGitCommands() }) buildOptions.NewLabel("start over") buildOptions.NewButton("rm ~/go/src & ~/go/pkg", func() { var newCmds [][]string var dirty bool = false for repo, _ := range me.allrepos { status := repo.getStatus() if status == "dirty" { dirty = true break } } newCmds = append(newCmds, []string{"cd", "."}) newCmds = append(newCmds, []string{"rm", "-rf", "go/src/"}) newCmds = append(newCmds, []string{"chmod", "700", "-R", "go/pkg/"}) newCmds = append(newCmds, []string{"rm", "-rf", "go/pkg/"}) if dirty { newCmds = append(newCmds, []string{"can't do this with dirty repos"}) doit.Disable() } else { doit.Enable() } me.script = newCmds setGitCommands() }) buildOptions.NewSeparator("endStatusScans") buildOptions.NewSeparator("endStatusScans") buildOptions.NewLabel("cmd") cmds = buildOptions.NewLabel("ls") buildOptions.NewLabel("--dry-run") dryrun = buildOptions.NewButton("show commands", func() { if goMake("--dry-run") { log.Warn("EVERYTHING MIGHT HAVE WORKED") } else { log.Warn("EVERYTHING WILL NOT WORK") dryrun.Disable() } }) buildOptions.NewLabel("Doit") doit = buildOptions.NewButton("run commands", func() { doit.Disable() log.Warn("should run the commands here") // true here means dryrun == true. it's confusingly named if goMake("--doit") { log.Warn("EVERYTHING WORKED") } else { log.Warn("EVERYTHING DID NOT WORK") } }) }