autotypist/docs.go

61 lines
1.3 KiB
Go
Raw Normal View History

package main
import (
"fmt"
"os"
"path/filepath"
"go.wit.com/gui"
2024-02-17 08:38:44 -06:00
"go.wit.com/lib/gui/repolist"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
func docsBox(vbox *gui.Node) {
group := vbox.NewGroup("Docs")
group.NewButton("make 'go.work' file", func() {
me.autotypistWindow.Disable()
goSrcDir := me.goSrcPwd.String()
filename := filepath.Join(goSrcDir, "go.work")
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
return
}
defer f.Close()
fmt.Fprintln(f, "go 1.21.4")
fmt.Fprintln(f, "")
fmt.Fprintln(f, "use (")
2024-02-17 08:38:44 -06:00
for _, repo := range repolist.AllRepos() {
2024-03-07 19:28:46 -06:00
if repo.Status.Exists("go.mod") {
2024-02-17 15:47:46 -06:00
fmt.Fprintln(f, "\t"+repo.Status.GoPath())
} else {
2024-02-17 15:47:46 -06:00
log.Info("missing go.mod for", repo.Status.Path())
2024-03-07 19:28:46 -06:00
// repo.Status.MakeRedomod()
}
}
fmt.Fprintln(f, ")")
me.autotypistWindow.Enable()
})
group.NewButton("run pkgsite", func() {
tmp := me.userHomePwd.String()
tmpDir := filepath.Join(tmp, "go/src")
os.Chdir(tmpDir)
pkgsite := filepath.Join(tmp, "go/bin", "pkgsite")
os.Unsetenv("GO111MODULE")
go shell.Run([]string{pkgsite})
shell.Run([]string{"ping", "-c", "3", "git.wit.org"})
})
2024-02-16 17:55:53 -06:00
group.NewButton("open docs in browser (localhost:8080)", func() {
me.autotypistWindow.Disable()
defer me.autotypistWindow.Enable()
shell.OpenBrowser("http://localhost:8080")
})
}