2024-02-11 01:00:05 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-11-06 16:02:11 -06:00
|
|
|
"embed"
|
2024-02-11 06:32:48 -06:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
2024-02-11 01:00:05 -06:00
|
|
|
"go.wit.com/gui"
|
|
|
|
"go.wit.com/lib/debugger"
|
|
|
|
"go.wit.com/lib/gadgets"
|
2024-03-01 07:44:02 -06:00
|
|
|
"go.wit.com/lib/gui/shell"
|
2024-02-11 01:00:05 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2024-11-07 07:03:13 -06:00
|
|
|
// sent from -ldflags
|
|
|
|
var VERSION string
|
2024-11-15 10:51:45 -06:00
|
|
|
var DATE string
|
2024-11-07 07:03:13 -06:00
|
|
|
|
2024-02-11 01:00:05 -06:00
|
|
|
// This is the beginning of the binary tree of GUI widgets
|
|
|
|
var myGui *gui.Node
|
|
|
|
|
2024-02-11 06:32:48 -06:00
|
|
|
var cBox *controlBox
|
2024-02-11 01:00:05 -06:00
|
|
|
|
|
|
|
// this is a basic window. the user can open and close it
|
|
|
|
var basicWindow *gadgets.BasicWindow
|
|
|
|
|
2024-11-06 16:02:11 -06:00
|
|
|
//go:embed resources/*
|
|
|
|
var resources embed.FS
|
|
|
|
|
2024-02-11 01:00:05 -06:00
|
|
|
func main() {
|
2024-11-06 13:46:15 -06:00
|
|
|
if argv.Repo == "" {
|
2024-02-11 13:56:59 -06:00
|
|
|
log.Info("You need to tell me what repo you want to work on")
|
|
|
|
println("")
|
|
|
|
println("go-deb --repo go.wit.com/apps/helloworld")
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
2024-02-11 01:00:05 -06:00
|
|
|
myGui = gui.New()
|
2024-11-16 00:05:07 -06:00
|
|
|
if !argv.Auto {
|
2024-11-06 16:09:02 -06:00
|
|
|
myGui.InitEmbed(resources)
|
|
|
|
}
|
2024-11-16 00:05:07 -06:00
|
|
|
myGui.Default()
|
2024-02-11 01:00:05 -06:00
|
|
|
|
|
|
|
basicWindow = makebasicWindow()
|
|
|
|
|
2024-11-06 16:31:23 -06:00
|
|
|
// todo: add the go.work file logic here
|
|
|
|
homeDir, _ := os.UserHomeDir()
|
|
|
|
filepath := filepath.Join(homeDir, "go/src", argv.Repo)
|
2024-02-11 13:56:59 -06:00
|
|
|
os.Chdir(filepath)
|
2024-02-11 06:32:48 -06:00
|
|
|
|
2024-02-11 21:49:39 -06:00
|
|
|
// scan the repo
|
2024-11-06 13:46:15 -06:00
|
|
|
cBox.addRepo(argv.Repo)
|
2024-02-20 23:13:26 -06:00
|
|
|
|
2024-02-11 21:49:39 -06:00
|
|
|
// look for a 'config' file in the repo
|
|
|
|
if cBox.readControlFile() == nil {
|
|
|
|
log.Warn("scan worked")
|
|
|
|
} else {
|
|
|
|
log.Warn("scan failed")
|
|
|
|
}
|
|
|
|
cBox.computeControlValues()
|
|
|
|
// verify the values for the package
|
|
|
|
|
2024-11-06 15:52:43 -06:00
|
|
|
if cBox.status == nil {
|
|
|
|
log.Info("argv.Repo =", argv.Repo)
|
|
|
|
log.Info("repo not found. Try:")
|
|
|
|
log.Info("")
|
|
|
|
log.Info(" go-clone", argv.Repo)
|
|
|
|
log.Info("")
|
|
|
|
os.Exit(-1)
|
|
|
|
}
|
|
|
|
|
2024-11-08 04:07:53 -06:00
|
|
|
// set the working directory to argv.Repo
|
|
|
|
log.Info("cd", cBox.status.Path())
|
|
|
|
os.Chdir(cBox.status.Path())
|
|
|
|
|
2024-11-16 00:05:07 -06:00
|
|
|
if argv.Auto {
|
2024-02-23 22:07:13 -06:00
|
|
|
shell.TestTerminalColor()
|
2024-11-06 15:52:43 -06:00
|
|
|
// basicWindow.Show() // broken gui package. convert to protobuf
|
2024-03-02 15:58:56 -06:00
|
|
|
if ok, err := cBox.buildPackage(); ok {
|
2024-11-06 17:51:49 -06:00
|
|
|
log.Info("build worked")
|
2024-02-11 13:56:59 -06:00
|
|
|
} else {
|
2024-03-01 07:44:02 -06:00
|
|
|
log.Warn("build failed:", err)
|
2024-02-20 23:13:26 -06:00
|
|
|
os.Exit(-1)
|
2024-02-11 13:56:59 -06:00
|
|
|
}
|
|
|
|
os.Exit(0)
|
2024-02-11 01:00:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// run the debugger if triggered from the commandline
|
|
|
|
if debugger.ArgDebug() {
|
|
|
|
go func() {
|
|
|
|
log.Sleep(2)
|
|
|
|
debugger.DebugWindow()
|
|
|
|
}()
|
|
|
|
}
|
2024-02-11 13:56:59 -06:00
|
|
|
|
|
|
|
basicWindow.Show()
|
|
|
|
// go will sit here until the window exits
|
|
|
|
gui.Watchdog()
|
|
|
|
os.Exit(0)
|
2024-02-11 01:00:05 -06:00
|
|
|
}
|