summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--globalBuildOptions.go8
-rw-r--r--globalDisplayOptions.go16
-rw-r--r--listWindow.go301
-rw-r--r--main.go9
-rw-r--r--repolist.go70
-rw-r--r--structs.go5
7 files changed, 56 insertions, 359 deletions
diff --git a/Makefile b/Makefile
index e6b74bf..edfb08b 100644
--- a/Makefile
+++ b/Makefile
@@ -5,8 +5,8 @@ all: build
./autotypist
stderr: build
- echo "writing to /tmp/autotypist.stderr"
- ./autotypist >/tmp/autotypist.stderr 2>&1
+ echo "writing to /tmp/autotypist.log"
+ ./autotypist >/tmp/autotypist.log 2>&1
goimports:
goimports -w *.go
@@ -15,7 +15,7 @@ goimports:
gocui: build
reset
- ./autotypist --gui gocui --tmp-log
+ ./autotypist --gui gocui >/tmp/autotypist.log 2>&1
build:
echo "build it!"
diff --git a/globalBuildOptions.go b/globalBuildOptions.go
index 44b6f8c..3c3b6ba 100644
--- a/globalBuildOptions.go
+++ b/globalBuildOptions.go
@@ -27,9 +27,9 @@ func quickCmd(fullpath string, cmd []string) bool {
var b bool
var output string
- if me.autoWorkingPwd.String() != fullpath {
- me.autoWorkingPwd.SetValue(fullpath)
- }
+// if me.autoWorkingPwd.String() != fullpath {
+// me.autoWorkingPwd.SetValue(fullpath)
+// }
if me.autoDryRun.Checked() {
log.Warn("RUN --dry-run", fullpath, cmd)
@@ -58,7 +58,7 @@ func globalBuildOptions(vbox *gui.Node) {
group1 := vbox.NewGroup("Global Build Options")
grid := group1.NewGrid("buildOptions", 2, 1)
- me.autoWorkingPwd = gadgets.NewOneLiner(grid, "working directory (pwd)")
+ // me.autoWorkingPwd = gadgets.NewOneLiner(grid, "working directory (pwd)")
me.userHomePwd = gadgets.NewOneLiner(grid, "user home")
me.goSrcPwd = gadgets.NewOneLiner(grid, "go src home")
diff --git a/globalDisplayOptions.go b/globalDisplayOptions.go
index c45a045..e5668c6 100644
--- a/globalDisplayOptions.go
+++ b/globalDisplayOptions.go
@@ -7,7 +7,7 @@ import (
"go.wit.com/gui"
"go.wit.com/lib/debugger"
- "go.wit.com/lib/gadgets"
+ "go.wit.com/lib/gui/gowit"
"go.wit.com/lib/gui/logsettings"
"go.wit.com/log"
// "go.wit.com/gui/gadgets"
@@ -102,7 +102,7 @@ func globalDisplayOptions(vbox *gui.Node) {
})
var tagsW *tagWindow
- group1.NewButton("tag Window", func() {
+ group1.NewButton("git tags Window", func() {
if tagsW == nil {
tagsW = makeTagWindow()
} else {
@@ -111,13 +111,15 @@ func globalDisplayOptions(vbox *gui.Node) {
})
var listallB *gui.Node
- var listW *gadgets.BasicWindow
- listallB = group1.NewButton("go.wit.com Window", func() {
+ listallB = group1.NewButton("go.wit.com", func() {
listallB.Disable()
- if listW == nil {
- listW = listWindow()
+ if me.lw == nil {
+ me.lw = gowit.ListWindow()
+ }
+ if me.lw.Hidden() {
+ me.lw.Show()
} else {
- listW.Toggle()
+ me.lw.Hide()
}
listallB.Enable()
})
diff --git a/listWindow.go b/listWindow.go
deleted file mode 100644
index 503eaa8..0000000
--- a/listWindow.go
+++ /dev/null
@@ -1,301 +0,0 @@
-package main
-
-import (
- "fmt"
- "io/ioutil"
- "net/http"
- "os"
- "path/filepath"
- "strconv"
- "strings"
- "time"
-
- "go.wit.com/gui"
- "go.wit.com/log"
-
- "go.wit.com/lib/gadgets"
- "go.wit.com/lib/gui/repostatus"
-)
-
-var lw *gadgets.BasicWindow
-
-var allsections []*section
-
-type witRepo struct {
- sec *section
- path *gui.Node
- downloadB *gui.Node
-}
-
-type section struct {
- name string
- hidden bool
-
- parent *gui.Node
- box *gui.Node
- group *gui.Node
- grid *gui.Node // where the repos are listed
- hideCB *gui.Node
- downloadAllB *gui.Node
- witRepos []*witRepo
-}
-
-func listWindow() *gadgets.BasicWindow {
- if lw != nil {
- lw.Toggle()
- return lw
- }
- lw = gadgets.NewBasicWindow(me.myGui, "go.wit.com repositories")
- lw.Custom = func() {
- log.Warn("got to close")
- }
-
- lw.Make()
- lw.StandardClose()
- lw.Draw()
- box := lw.Box()
- group := box.NewGroup("list")
- group.NewButton("make new go version list", func() {
- dumpVersions()
- })
-
- var lines []string
- var curs *section
-
- lines = dumpURL("https://go.wit.com/list")
- for i, line := range lines {
- if line == "" {
- continue
- }
- if line[0] == '#' {
- curs = NewSection(group, line)
- log.Warn("new group:", line)
- continue
- }
- log.Warn(i, line)
- parts := strings.Split(line, " ")
- if curs != nil {
- curs.add(parts[0])
- }
- }
- for i, sec := range allsections {
- log.Info("section name:", sec.name, "hidden:", sec.hidden, i)
- parts := strings.Split(sec.name, " ")
- if len(parts) > 1 {
- if parts[1] != "Applications" {
- sec.Hide()
- }
- }
- }
- // lw.Toggle()
- return lw
-}
-
-func downloadRepo(path string) bool {
- log.Info("downloading", path, "here")
- os.Setenv("GO111MODULE", "off")
-
- goSrcDir := me.goSrcPwd.String()
- if !quickCmd(goSrcDir, []string{"go", "get", "-v", path}) {
- log.Info("go get failed")
- return false
- }
-
- fullpath := filepath.Join(goSrcDir, path)
- if !quickCmd(fullpath, []string{"go", "get", "-v", "-u", "."}) {
- log.Info("go get depends failed")
- return false
- }
- if me.autoDryRun.Checked() {
- return false
- }
- return true
-}
-
-func (r *witRepo) doDownload() bool {
- if me.autoDryRun.Checked() {
- r.downloadB.SetLabel("uncheck --dry-run")
- return false
- }
- if r.downloadB.String() == "downloaded" {
- log.Info("skipping already downloaded", r.path.String())
- return true
- }
- if downloadRepo(r.path.String()) {
- log.Info("download", r.path.String(), "worked")
- r.downloadB.SetLabel("downloaded")
- r.downloadB.Disable()
- } else {
- r.downloadB.SetLabel("failed")
- log.Info("download", r.path.String(), "failed")
- return false
- }
- return true
-}
-
-func (s *section) add(path string) {
- if s == nil {
- return
- }
- tmp := new(witRepo)
- tmp.sec = s
- tmp.path = s.grid.NewLabel(path)
- tmp.downloadB = s.grid.NewButton("download", func() {
- lw.Disable()
- tmp.doDownload()
- lw.Enable()
- })
- if repostatus.VerifyLocalGoRepo(path) {
- log.Verbose("newRepo actually exists", path)
- tmp.downloadB.SetLabel("downloaded")
- tmp.downloadB.Disable()
- }
-
- s.witRepos = append(s.witRepos, tmp)
-}
-
-func NewSection(parent *gui.Node, desc string) *section {
- news := new(section)
- news.name = desc
- news.parent = parent
- news.box = news.parent.NewBox("bw vbox", true)
- news.group = news.box.NewGroup(desc)
- news.hideCB = news.box.NewCheckbox("hide")
- news.hideCB.Custom = func() {
- news.toggle()
- }
- news.downloadAllB = news.box.NewButton("download all", func() {
- lw.Disable()
- log.Warn("Download all here")
- for i, wrepo := range news.witRepos {
- log.Warn("download:", i, wrepo.path.String())
- wrepo.doDownload()
- //wrepo.path.Show()
- //wrepo.downloadB.Show()
- }
- lw.Enable()
- })
- news.grid = news.parent.NewGrid("sections", 2, 1)
- allsections = append(allsections, news)
- return news
-}
-
-func (s *section) toggle() {
- log.Warn(s.name)
- if s.hidden {
- s.hidden = false
- for i, wrepo := range s.witRepos {
- log.Warn(i, wrepo.path.String())
- wrepo.path.Show()
- wrepo.downloadB.Show()
- }
- } else {
- s.Hide()
- }
-}
-
-func (s *section) Hide() {
- s.hidden = true
- s.hideCB.SetChecked(true)
- for i, wrepo := range s.witRepos {
- log.Warn(i, wrepo.path.String())
- wrepo.path.Hide()
- wrepo.downloadB.Hide()
- }
-}
-
-/*
-func dumpURL(url string) string {
- resp, err := http.Get(url)
- if err != nil {
- return ""
- }
- defer resp.Body.Close()
-
- return resp.Body.String()
-
- _, err = io.Copy(os.Stdout, resp.Body)
- if err != nil {
- return ""
- }
-}
-*/
-
-func dumpURL(url string) []string {
- resp, err := http.Get(url)
- if err != nil {
- return nil
- }
- defer resp.Body.Close()
-
- bodyBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- return nil
- }
-
- return strings.Split(string(bodyBytes), "\n")
-}
-
-func dumpVersions() {
- f, _ := os.OpenFile("/tmp/go.wit.com.versions", os.O_WRONLY|os.O_CREATE, 0600)
- defer f.Close()
- for _, sec := range allsections {
- for _, wrepo := range sec.witRepos {
- r, ok := me.allrepos[wrepo.path.String()]
- if ok {
- _, out := r.status.RunCmd([]string{"git", "log", "-1", "--format=%at", r.lastTag.String()})
- out = strings.TrimSpace(out)
-
- // Convert the string to an integer
- gitTagTimestampInt, err := strconv.ParseInt(out, 10, 64)
- if err != nil {
- fmt.Println("Error converting timestamp:", err)
- return
- }
-
- // Parse the Unix timestamp into a time.Time object
- gitTagDate := time.Unix(gitTagTimestampInt, 0)
-
- // Get the current time
- currentTime := time.Now()
-
- // Calculate the duration between the git tag date and the current time
- duration := currentTime.Sub(gitTagDate)
-
- // s := fmt.Sprint(duration)
- // fmt.Println("Duration since the git tag date:", s)
-
- // fmt.Println("Default formatting:", duration.String())
- // fmt.Println("Custom formatting:", formatDuration(duration))
- log.Warn("found:", wrepo.path.String(), r.lastTag.String(), out, formatDuration(duration))
- fmt.Fprintln(f, wrepo.path.String(), r.lastTag.String(), out)
- }
- //wrepo.path.Show()
- }
- }
-}
-
-func formatDuration(d time.Duration) string {
- seconds := int(d.Seconds()) % 60
- minutes := int(d.Minutes()) % 60
- hours := int(d.Hours()) % 24
- days := int(d.Hours()) / 24
-
- result := ""
- if days > 0 {
- result += fmt.Sprintf("%dd ", days)
- return result
- }
- if hours > 0 {
- result += fmt.Sprintf("%dh ", hours)
- return result
- }
- if minutes > 0 {
- result += fmt.Sprintf("%dm ", minutes)
- return result
- }
- if seconds > 0 {
- result += fmt.Sprintf("%ds", seconds)
- }
- return result
-}
diff --git a/main.go b/main.go
index fafd202..a5a549e 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ import (
"embed"
"time"
+ "go.wit.com/lib/debugger"
"go.wit.com/log"
"go.wit.com/gui"
@@ -20,12 +21,14 @@ func main() {
me.myGui.InitEmbed(resToolkit)
me.myGui.Default()
- me.autotypistWindow = me.myGui.NewWindow("autotypist for GO & git. it types faster than you can.")
+ me.autotypistWindow = me.myGui.NewWindow("autotypist: it types faster than you can.")
box := me.autotypistWindow.NewBox("bw hbox", true)
vbox1 := box.NewVerticalBox("BOX1")
globalDisplayOptions(vbox1)
- debuggerBox(vbox1)
+ if debugger.ArgDebug() {
+ debuggerBox(vbox1)
+ }
vbox2 := box.NewVerticalBox("BOX2")
globalBuildOptions(vbox2)
@@ -70,7 +73,7 @@ func main() {
})
/*
s := fmt.Sprint(duration)
- me.autoWorkingPwd.SetText(s)
+ // me.autoWorkingPwd.SetText(s)
*/
})
}
diff --git a/repolist.go b/repolist.go
index 749d930..61a53f4 100644
--- a/repolist.go
+++ b/repolist.go
@@ -154,25 +154,6 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
}
me.reposwin.Enable()
})
- newRepo.endBox.NewButton("build", func() {
- switch newRepo.status.RepoType() {
- case "binary":
- log.Info("compile here. Show()")
- case "library":
- log.Info("library here. Hide()")
- default:
- log.Info("unknown. Show()")
- }
-
- /*
- err, output := newRepo.status.RunCmd([]string{"go", "list", "-f", "'{{if eq .Name \"main\"}}binary{{else}}library{{end}}'"})
- if err != nil {
- log.Info("package is: unknown", err)
- return
- }
- output = strings.Trim(output, "'")
- */
- })
newRepo.status = repostatus.NewRepoStatusWindow(newRepo.path)
newRepo.hidden = false
@@ -180,6 +161,22 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
newRepo.status.SetDevelWorkingName(devel)
newRepo.status.SetUserWorkingName(user)
+ var showBuildB bool = false
+ switch newRepo.status.RepoType() {
+ case "binary":
+ log.Info("compile here. Show()")
+ showBuildB = true
+ case "library":
+ log.Info("library here. Hide()")
+ default:
+ log.Info("unknown. Show()")
+ }
+ if showBuildB {
+ newRepo.endBox.NewButton("build", func() {
+ newRepo.status.Build()
+ })
+ }
+
me.allrepos[path] = newRepo
}
@@ -246,20 +243,20 @@ func repolistWindow() {
}
func showApps() {
- for _, repo := range me.allrepos {
- switch repo.status.RepoType() {
- case "binary":
- log.Info("compile here. Show()")
- repo.Show()
- case "library":
- log.Info("library here. Hide()")
- repo.Hide()
- default:
- log.Info("unknown. Show()")
- repo.Hide()
- }
-
+ for _, repo := range me.allrepos {
+ switch repo.status.RepoType() {
+ case "binary":
+ log.Info("compile here. Show()")
+ repo.Show()
+ case "library":
+ log.Info("library here. Hide()")
+ repo.Hide()
+ default:
+ log.Info("unknown. Show()")
+ repo.Hide()
}
+
+ }
}
func repoAllButtons(box *gui.Node) {
@@ -306,13 +303,7 @@ func repoAllButtons(box *gui.Node) {
me.reposwin.Enable()
})
- box2.NewButton("show apps", func() {
- me.reposwin.Disable()
- showApps()
- me.reposwin.Enable()
- })
-
- box2.NewButton("build all", func() {
+ box2.NewButton("test all builds", func() {
me.reposwin.Disable()
defer me.reposwin.Enable()
showApps()
@@ -334,7 +325,6 @@ func repoAllButtons(box *gui.Node) {
log.Info("every build worked !!!")
log.Info("")
})
-
}
func mergeAllDevelToMain() bool {
diff --git a/structs.go b/structs.go
index 2cda697..c89698a 100644
--- a/structs.go
+++ b/structs.go
@@ -15,6 +15,9 @@ type autoType struct {
autotypistWindow *gui.Node
+ // the window from the /lib/gui/gowit package
+ lw *gadgets.BasicWindow
+
reposwin *gadgets.BasicWindow
reposbox *gui.Node
reposgrid *gui.Node
@@ -52,7 +55,7 @@ type autoType struct {
scanEveryMinute *gui.Node
// The current working directory
- autoWorkingPwd *gadgets.OneLiner
+ // autoWorkingPwd *gadgets.OneLiner
// what is being used as your home dir
userHomePwd *gadgets.OneLiner