summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--argv.go16
-rwxr-xr-xbuild4
-rw-r--r--complete.go43
-rw-r--r--main.go25
-rw-r--r--structs.go14
6 files changed, 95 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 9a2b36d..cc96e07 100644
--- a/Makefile
+++ b/Makefile
@@ -30,5 +30,5 @@ goimports:
goimports -w *.go
clean:
- rm -f ~/go/lib/go-gui/*.so
+ rm -f ~/go/lib/go-gui/*.so *.deb go-gui-toolkits
go-mod-clean purge
diff --git a/argv.go b/argv.go
new file mode 100644
index 0000000..32d29cd
--- /dev/null
+++ b/argv.go
@@ -0,0 +1,16 @@
+// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
+// Use of this source code is governed by the GPL 3.0
+
+package main
+
+var argv args
+
+type args struct {
+ Rebuild *EmptyCmd `arg:"subcommand:rebuild" help:"rebuild the GO GUI plugins"`
+ DryRun bool `arg:"--dry-run" help:"only show what would be packaged"`
+ Verbose bool `arg:"--verbose" help:"be loud about it"`
+ Force bool `arg:"--force" help:"rebuild everything"`
+}
+
+type EmptyCmd struct {
+}
diff --git a/build b/build
index 4e31997..b3ad772 100755
--- a/build
+++ b/build
@@ -4,5 +4,5 @@ rm -rf ~/go/lib/*
go-gui-toolkits
ls -lt ~/go/lib/
-mkdir -p files/usr/lib/go-gui-toolkits
-cp -a ~/go/lib/*.so files/usr/lib/go-gui-toolkits/
+mkdir -p files/usr/lib/plugins
+cp -a ~/go/lib/plugins/*.so files/usr/lib/plugins
diff --git a/complete.go b/complete.go
new file mode 100644
index 0000000..ef2815e
--- /dev/null
+++ b/complete.go
@@ -0,0 +1,43 @@
+// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
+// Use of this source code is governed by the GPL 3.0
+
+package main
+
+import (
+ "fmt"
+ "strings"
+
+ "go.wit.com/dev/alexflint/arg"
+ "go.wit.com/lib/protobuf/argvpb"
+)
+
+// sent via -ldflags
+var VERSION string
+var BUILDTIME string
+
+// used for shell auto completion
+var APPNAME string = "go-gui-toolkits" // todo: get this from $0
+
+// sends the strings to bash or zsh that will be your options
+func (a args) DoAutoComplete() error {
+ var err error
+ me.pp, err = arg.ParseFlagsArgv(&argv)
+ if err != nil {
+ fmt.Fprintf(argvpb.Stddbg, "go-args parseFlagsArgv(%v) finished autocomplete\n", err)
+ }
+ return err
+}
+
+func (args) MustParse() error {
+ me.pp = arg.MustParseArgv(&argv)
+ return nil
+}
+
+func (args) Match() bool {
+ if argvpb.PB.GetCmd() == "" {
+ matches := []string{"all", "--verbose", "--version"}
+ fmt.Fprintf(argvpb.Stdout, " %s", strings.Join(matches, " "))
+ return true
+ }
+ return false
+}
diff --git a/main.go b/main.go
index 44e6989..772259c 100644
--- a/main.go
+++ b/main.go
@@ -3,32 +3,45 @@ package main
import (
"os"
+ "go.wit.com/lib/env"
+ "go.wit.com/lib/protobuf/argvpb"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log"
)
// go will sit here until the window exits
func main() {
- forge, err := forgepb.Init()
+ me = new(mainType)
+ argvpb.Init(&argv, APPNAME, BUILDTIME, VERSION) // adds shell auto-complete
+ env.LoadEtc() // loads settings from /etc/mirrors.d/
+ env.PrintTable()
+
+ var err error
+ me.forge, err = forgepb.Init()
if err != nil {
- log.Info("forge not installed", err)
+ log.Info("you need to install forge first", err)
os.Exit(-1)
}
+ if argv.Rebuild != nil {
+ // rebuild here
+ os.Exit(0)
+ }
+
cmd := []string{"make", "install"}
- if repo := forge.Repos.FindByNamespace("go.wit.com/toolkits/gocui"); repo != nil {
+ if repo := me.forge.Repos.FindByNamespace("go.wit.com/toolkits/gocui"); repo != nil {
repo.RunVerbose(cmd)
}
- if repo := forge.Repos.FindByNamespace("go.wit.com/toolkits/andlabs"); repo != nil {
+ if repo := me.forge.Repos.FindByNamespace("go.wit.com/toolkits/andlabs"); repo != nil {
repo.RunVerbose(cmd)
}
- if repo := forge.Repos.FindByNamespace("go.wit.com/toolkits/nocui"); repo != nil {
+ if repo := me.forge.Repos.FindByNamespace("go.wit.com/toolkits/nocui"); repo != nil {
repo.RunVerbose(cmd)
}
- if repo := forge.Repos.FindByNamespace("go.wit.com/toolkits/fyne"); repo != nil {
+ if repo := me.forge.Repos.FindByNamespace("go.wit.com/toolkits/fyne"); repo != nil {
repo.RunVerbose(cmd)
}
}
diff --git a/structs.go b/structs.go
new file mode 100644
index 0000000..fdcae67
--- /dev/null
+++ b/structs.go
@@ -0,0 +1,14 @@
+package main
+
+import (
+ "go.wit.com/dev/alexflint/arg"
+ "go.wit.com/lib/protobuf/forgepb"
+)
+
+var me *mainType
+
+// this app's variables
+type mainType struct {
+ pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
+ forge *forgepb.Forge // your customized repo preferences and settings
+}