diff options
| author | Jeff Carr <[email protected]> | 2024-11-07 13:03:42 -0600 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-11-07 13:03:42 -0600 | 
| commit | 1b7db666f166ce375a377858404d9108a81e0e76 (patch) | |
| tree | a63a5821c452e3ff2ef928a4084e5c427045b6a4 | |
| parent | d6f9401f6153abeb5b5ab1df61355569fc9d5a71 (diff) | |
update argv code
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | Makefile | 10 | ||||
| -rw-r--r-- | argv.go | 39 | ||||
| -rw-r--r-- | debugger.go | 6 | ||||
| -rw-r--r-- | main.go | 4 | 
4 files changed, 51 insertions, 8 deletions
@@ -1,5 +1,13 @@ +VERSION = $(shell git describe --tags) +  all: -	GO111MODULE=off go build -v -x +	GO111MODULE=off go build -v -x \ +		    -ldflags "-X main.VERSION=${VERSION}" +	./helloworld + +install: +	GO111MODULE=off go install -v -x \ +		    -ldflags "-X main.VERSION=${VERSION}"  	./helloworld  gocui: @@ -0,0 +1,39 @@ +package main + +import ( +	"os" + +	"github.com/alexflint/go-arg" +) + +/* +	this parses the command line arguements + +	this enables command line options from other packages like 'gui' and 'log' +*/ + +var argv args + +type args struct { +	Demo      string `arg:"positional"                   help:"this is just a demo"` +} + +func (a args) Description() string { +	return ` +This helloworld example demonstrates the 'gui' plugin toolkits +` +} + +func init() { +	pp := arg.MustParse(&argv) + +	// for very new users or users unfamilar with the command line, this may help them +	if argv.Demo == "version" || argv.Demo == "help" || argv.Demo == "?" { +		pp.WriteHelp(os.Stdout) +		os.Exit(0) +	} +} + +func (args) Version() string { +	return "helloworld " + VERSION +} diff --git a/debugger.go b/debugger.go index 116d549..f7a6aca 100644 --- a/debugger.go +++ b/debugger.go @@ -5,17 +5,11 @@ package main  */  import ( -	"go.wit.com/dev/alexflint/arg"  	"go.wit.com/lib/debugger"  	"go.wit.com/log"  ) -var args struct { -} -  func init() { -	arg.MustParse(&args) -  	if debugger.ArgDebug() {  		log.Info("cmd line --debugger == true")  		go func() { @@ -1,4 +1,3 @@ -// This creates a simple helloworld window  package main  import ( @@ -6,6 +5,9 @@ import (  	"go.wit.com/log"  ) +// sent from -ldflags +var VERSION string +  // This is the beginning of our binary tree of widgets  var myGui *gui.Node  | 
