diff options
| author | Jeff Carr <[email protected]> | 2025-10-29 14:15:18 -0500 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-29 14:15:18 -0500 | 
| commit | 7d57129d8530d6a8393fc7b8060ad02aaf028cea (patch) | |
| tree | f5f58221611164929e9e83383a935675ac03dd12 | |
| parent | 6925e1ccb0d75a0518992d210e5dcf8a4e1a386f (diff) | |
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | argv.go | 16 | ||||
| -rwxr-xr-x | build | 4 | ||||
| -rw-r--r-- | complete.go | 43 | ||||
| -rw-r--r-- | main.go | 25 | ||||
| -rw-r--r-- | structs.go | 14 | 
6 files changed, 95 insertions, 9 deletions
@@ -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 @@ -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 { +} @@ -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 +} @@ -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 +}  | 
