2024-01-09 15:34:53 -06:00
|
|
|
package repostatus
|
|
|
|
|
2024-01-18 00:57:43 -06:00
|
|
|
import (
|
2024-02-12 18:16:03 -06:00
|
|
|
"strings"
|
|
|
|
|
2024-01-09 15:34:53 -06:00
|
|
|
"go.wit.com/log"
|
2024-01-18 00:57:43 -06:00
|
|
|
// "go.wit.com/gui/gui"
|
2024-01-09 15:34:53 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// reports externally if something has changed
|
|
|
|
// since the last time it was asked about it
|
2024-01-10 18:18:01 -06:00
|
|
|
func (rs *RepoStatus) Changed() bool {
|
2024-01-18 00:57:43 -06:00
|
|
|
if !rs.Ready() {
|
|
|
|
return false
|
|
|
|
}
|
2024-01-19 18:25:37 -06:00
|
|
|
|
|
|
|
return rs.changed
|
2024-01-09 15:34:53 -06:00
|
|
|
}
|
|
|
|
|
2024-01-10 18:18:01 -06:00
|
|
|
func (rs *RepoStatus) Draw() {
|
2024-01-18 00:57:43 -06:00
|
|
|
if !rs.Ready() {
|
|
|
|
return
|
|
|
|
}
|
2024-01-10 18:18:01 -06:00
|
|
|
log.Log(CHANGE, "Draw() window ready =", rs.ready)
|
2024-01-14 10:00:42 -06:00
|
|
|
rs.window.TestDraw()
|
2024-01-09 15:34:53 -06:00
|
|
|
}
|
2024-01-13 20:30:33 -06:00
|
|
|
|
2024-01-10 18:18:01 -06:00
|
|
|
func (rs *RepoStatus) Show() {
|
2024-01-18 00:57:43 -06:00
|
|
|
if !rs.Ready() {
|
|
|
|
return
|
|
|
|
}
|
2024-01-10 18:18:01 -06:00
|
|
|
log.Log(CHANGE, "Show() window ready =", rs.ready)
|
|
|
|
rs.window.Show()
|
2024-01-09 15:34:53 -06:00
|
|
|
}
|
|
|
|
|
2024-01-10 18:18:01 -06:00
|
|
|
func (rs *RepoStatus) Hide() {
|
2024-01-18 00:57:43 -06:00
|
|
|
if !rs.Ready() {
|
|
|
|
return
|
|
|
|
}
|
2024-01-10 18:18:01 -06:00
|
|
|
log.Log(CHANGE, "Hide() window ready =", rs.ready)
|
|
|
|
rs.window.Hide()
|
2024-01-09 15:34:53 -06:00
|
|
|
}
|
|
|
|
|
2024-01-10 18:18:01 -06:00
|
|
|
func (rs *RepoStatus) Toggle() {
|
2024-01-18 00:57:43 -06:00
|
|
|
if !rs.Ready() {
|
|
|
|
return
|
|
|
|
}
|
2024-01-10 18:18:01 -06:00
|
|
|
log.Log(CHANGE, "Toggle() window ready =", rs.ready)
|
2024-02-11 18:56:55 -06:00
|
|
|
if rs.window.Hidden() {
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.Show()
|
2024-01-09 15:34:53 -06:00
|
|
|
} else {
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.Hide()
|
2024-01-09 15:34:53 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-10 18:18:01 -06:00
|
|
|
func (rs *RepoStatus) Ready() bool {
|
2024-01-18 00:57:43 -06:00
|
|
|
if rs == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if rs.window == nil {
|
|
|
|
return false
|
|
|
|
}
|
2024-01-10 18:18:01 -06:00
|
|
|
return rs.ready
|
2024-01-09 15:34:53 -06:00
|
|
|
}
|
|
|
|
|
2024-01-14 10:00:42 -06:00
|
|
|
/*
|
2024-01-10 18:18:01 -06:00
|
|
|
func (rs *RepoStatus) Initialized() bool {
|
2024-01-09 15:34:53 -06:00
|
|
|
log.Log(CHANGE, "checking Initialized()")
|
2024-01-10 18:18:01 -06:00
|
|
|
if rs == nil {return false}
|
|
|
|
if rs.parent == nil {return false}
|
2024-01-09 15:34:53 -06:00
|
|
|
return true
|
|
|
|
}
|
2024-01-14 10:00:42 -06:00
|
|
|
*/
|
2024-02-12 18:16:03 -06:00
|
|
|
|
|
|
|
func (rs *RepoStatus) RepoType() string {
|
|
|
|
err, output := rs.RunCmd([]string{"go", "list", "-f", "'{{if eq .Name \"main\"}}binary{{else}}library{{end}}'"})
|
|
|
|
if err == nil {
|
|
|
|
output = strings.Trim(output, "'")
|
|
|
|
log.Info("go package is:", output)
|
|
|
|
return output
|
|
|
|
}
|
|
|
|
log.Info("package is: unknown", err)
|
|
|
|
return ""
|
|
|
|
}
|