summaryrefslogtreecommitdiff
path: root/globalResetOptions.go
blob: fca623ce9155ef4bd5cf78704f037bdb6141d47f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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("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", "/home/jcarr/"})
		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 = group2.NewTextbox("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")
		}
	})
}