autotypist/globalResetOptions.go

39 lines
1.1 KiB
Go
Raw Normal View History

package main
import (
"path/filepath"
"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")
me.deleteGoSrcPkgB = buildOptions.NewButton("rm ~/go/src & ~/go/pkg", func() {
for _, repo := range me.allrepos {
// status := repo.getStatus()
if repo.checkDirty() {
log.Warn("repo is dirty. commit your changes first", repo.String())
me.deleteGoSrcPkgB.SetLabel("rm ~/go/src (can't. dirty repos)")
return
}
}
log.Warn("no repos have uncommited changes")
log.Warn("TODO: check things are pushed and check every dir in go/src/")
me.deleteGoSrcPkgB.SetLabel("ARE YOU SURE?")
if me.deleteGoSrcPkgB.String() == "ARE YOU SURE?" {
homeDir := me.userHomePwd.String()
fullpath := filepath.Join(homeDir, "go")
gosrc := filepath.Join(fullpath, "src")
gopkg := filepath.Join(fullpath, "pkg")
quickCmd(fullpath, []string{"rm", "-rf", gosrc})
quickCmd(fullpath, []string{"chmod", "700", "-R", gopkg})
quickCmd(fullpath, []string{"rm", "-rf", gopkg})
}
})
}