From fd65e8f02e59f115c33fe73475742693027eebbd Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 15 Nov 2024 20:04:22 -0600 Subject: try to add --no-gui --- Makefile | 21 ++------------------- args.go | 32 -------------------------------- argv.go | 33 +++++++++++++++++++++++++++++++++ main.go | 4 ++++ 4 files changed, 39 insertions(+), 51 deletions(-) delete mode 100644 args.go create mode 100644 argv.go diff --git a/Makefile b/Makefile index f46e907..b37bb3f 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,12 @@ all: - @GO111MODULE=off go build @echo @echo This is the core gui package 'go.wit.com/gui/gui' @echo @echo It creates a binary tree of widgets @echo The widgets are things like Windows, Buttons, Labels, etc @echo - @go vet - -note-about-golang: -ifeq ($(GO111MODULE),) - @echo - @echo If you are compiling this here, you probably want to set GO111MODULE - @echo - @echo Setting GO111MODULE means that the version you are compiling has plugins - @echo that get compiled against this current running version of the code - @echo Otherwise, the GO language plugins can complain about being compiled against - @echo mis-matched versions - @echo - @echo export GO111MODULE=off - @echo -endif + @GO111MODULE=off go vet + @echo go vet: this go library package builds okay goimports: goimports -w *.go @@ -38,6 +24,3 @@ update: doc: godoc -v - -submit-to-docs: - GOPROXY=https://proxy.golang.org GO111MODULE=on go get go.wit.com/gui@v1.0.0 diff --git a/args.go b/args.go deleted file mode 100644 index 861d55b..0000000 --- a/args.go +++ /dev/null @@ -1,32 +0,0 @@ -package gui - -import ( - "go.wit.com/dev/alexflint/arg" -) - -var argGui ArgsGui - -/* -This struct can be used with the go-arg package. These -are the generic default command line arguments for the 'GUI' package -*/ -type ArgsGui struct { - GuiPlugin string `arg:"--gui" help:"Use this gui toolkit [andlabs,gocui,nocui,nogui]"` - GuiVerbose bool `arg:"--gui-verbose" help:"enable all logging"` -} - -/* -used for command line options. -This allows you to control the toolkit settings from the command line - - --debugger # opens the debugger - --gui andlabs # loads the GTK toolkit on linux or Cocoa on mac - --gui gocui # runs your program in the terminal in ncurses-like mode -*/ -func ArgToolkit() string { - return argGui.GuiPlugin -} - -func init() { - arg.Register(&argGui) -} diff --git a/argv.go b/argv.go new file mode 100644 index 0000000..7d687e8 --- /dev/null +++ b/argv.go @@ -0,0 +1,33 @@ +package gui + +import ( + "go.wit.com/dev/alexflint/arg" +) + +var argGui ArgsGui + +/* +This struct can be used with the go-arg package. These +are the generic default command line arguments for the 'GUI' package +*/ +type ArgsGui struct { + NoGui bool `arg:"--no-gui" help:"ignore all these gui problems"` + GuiPlugin string `arg:"--gui" help:"Use this gui toolkit [andlabs,gocui,nocui,stdin]"` + GuiVerbose bool `arg:"--gui-verbose" help:"enable all logging"` +} + +/* +used for command line options. +This allows you to control the toolkit settings from the command line + + --debugger # opens the debugger + --gui andlabs # loads the GTK toolkit on linux or Cocoa on mac + --gui gocui # runs your program in the terminal in ncurses-like mode +*/ +func ArgToolkit() string { + return argGui.GuiPlugin +} + +func init() { + arg.Register(&argGui) +} diff --git a/main.go b/main.go index 31f47f2..f04cc3c 100644 --- a/main.go +++ b/main.go @@ -263,6 +263,10 @@ func New() *Node { // try to load andlabs, if that doesn't work, fall back to the console func (n *Node) Default() *Node { var err error + if argGui.NoGui { + log.Log(WARN, "--no-gui chill Winston. I don't need no gui") + return n + } if argGui.GuiPlugin != "" { log.Log(WARN, "New.Default() try toolkit =", argGui.GuiPlugin) if n, err = n.LoadToolkit(argGui.GuiPlugin); err == nil { -- cgit v1.2.3