using args.Register()

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-12-29 17:24:16 -06:00
parent 7313c83e69
commit 4eae0a3e07
2 changed files with 15 additions and 9 deletions

18
args.go
View File

@ -4,19 +4,25 @@ import (
arg "github.com/alexflint/go-arg" arg "github.com/alexflint/go-arg"
) )
var guiArg GuiArgs var argGui ArgsGui
// This struct can be used with the go-arg package // This struct can be used with the go-arg package
type GuiArgs struct { type ArgsGui struct {
Gui string `arg:"--gui" help:"Use this gui toolkit [andlabs,gocui,nocui]"`
GuiDebug bool `arg:"--gui-debug" help:"open the GUI debugger"` GuiDebug bool `arg:"--gui-debug" help:"open the GUI debugger"`
GuiPlugin string `arg:"--gui" help:"Use this gui toolkit [andlabs,gocui,nocui]"`
GuiVerbose bool `arg:"--gui-verbose" help:"enable all logging"` GuiVerbose bool `arg:"--gui-verbose" help:"enable all logging"`
} }
func init() { func init() {
arg.Register(&guiArg) arg.Register(&argGui)
} }
func GetArg(a string) bool { // returns the toolkit
return guiArg.GuiDebug func ArgToolkit() string {
return argGui.GuiPlugin
}
// returns true if --gui-debug was passed from the command line
func ArgDebug() bool {
return argGui.GuiDebug
} }

View File

@ -123,9 +123,9 @@ func New() *Node {
// try to load andlabs, if that doesn't work, fall back to the console // try to load andlabs, if that doesn't work, fall back to the console
func (n *Node) Default() *Node { func (n *Node) Default() *Node {
if (guiArg.Gui != "") { if (argGui.GuiPlugin != "") {
log(logError, "New.Default() try toolkit =", guiArg.Gui) log(logError, "New.Default() try toolkit =", argGui.GuiPlugin)
return n.LoadToolkit(guiArg.Gui) return n.LoadToolkit(argGui.GuiPlugin)
} }
// if DISPLAY isn't set, return since gtk can't load // if DISPLAY isn't set, return since gtk can't load
// TODO: figure out how to check what to do in macos and mswindows // TODO: figure out how to check what to do in macos and mswindows