day1
This commit is contained in:
commit
2da467be82
|
@ -0,0 +1,3 @@
|
||||||
|
*.swp
|
||||||
|
go.*
|
||||||
|
*.pb.go
|
|
@ -0,0 +1,10 @@
|
||||||
|
# git remote add github git@github.com:wit-go/gui-debugger.git
|
||||||
|
|
||||||
|
all: goimports vet
|
||||||
|
@echo common init code for common packages
|
||||||
|
|
||||||
|
goimports:
|
||||||
|
goimports -w *.go
|
||||||
|
|
||||||
|
vet:
|
||||||
|
@GO111MODULE=off go vet
|
|
@ -0,0 +1,42 @@
|
||||||
|
package init
|
||||||
|
|
||||||
|
// initializes logging and command line options
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/dev/alexflint/arg"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
var INFO *log.LogFlag
|
||||||
|
var POLL *log.LogFlag
|
||||||
|
var CHAN *log.LogFlag
|
||||||
|
var WARN *log.LogFlag
|
||||||
|
|
||||||
|
var argDebugger ArgsDebugger
|
||||||
|
|
||||||
|
// This struct can be used with the go-arg package
|
||||||
|
type ArgsDebugger struct {
|
||||||
|
Debugger bool `arg:"--debugger" help:"open the debugger window"`
|
||||||
|
Logger bool `arg:"--logger" help:"open the log.* control window"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns true if --gui-debug was passed from the command line
|
||||||
|
func ArgDebug() bool {
|
||||||
|
return argDebugger.Debugger
|
||||||
|
}
|
||||||
|
|
||||||
|
func ArgLogger() bool {
|
||||||
|
return argDebugger.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func Debugger() {
|
||||||
|
arg.Register(&argDebugger)
|
||||||
|
|
||||||
|
full := "go.wit.com/bug/debugger"
|
||||||
|
short := "bugger"
|
||||||
|
|
||||||
|
INFO = log.NewFlag("INFO", false, full, short, "simple debugging Info()")
|
||||||
|
POLL = log.NewFlag("POLL", false, full, short, "watch the debugger poll things")
|
||||||
|
CHAN = log.NewFlag("CHAN", true, full, short, "chan() test code output")
|
||||||
|
WARN = log.NewFlag("WARN", true, full, short, "should warn the user")
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package init
|
||||||
|
|
||||||
|
// initializes logging and command line options
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/dev/alexflint/arg"
|
||||||
|
"go.wit.com/gui"
|
||||||
|
)
|
||||||
|
|
||||||
|
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 {
|
||||||
|
GuiPluginHack string `arg:"--gui-check-plugin" help:"hack to verify GO plugins load"`
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// this should never happen because this is before go-args MustParse()
|
||||||
|
if argGui.GuiPluginHack != "" {
|
||||||
|
// does os.Exec() and does not return
|
||||||
|
gui.TestPluginAndExit()
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// after go-args MustParse & user configuration
|
||||||
|
// the gui package can pull out the final settings and init() the GO Plugin GUI Toolkit
|
||||||
|
func postMustParse(s string) string {
|
||||||
|
switch s {
|
||||||
|
case "PluginHack":
|
||||||
|
return argGui.GuiPluginHack
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Gui() *gui.Node {
|
||||||
|
arg.Register(&argDebugger)
|
||||||
|
|
||||||
|
return gui.PreInit(postMustParse)
|
||||||
|
}
|
Loading…
Reference in New Issue