72 lines
1.9 KiB
Go
72 lines
1.9 KiB
Go
package prep
|
|
|
|
// 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")
|
|
}
|
|
|
|
// Versioned is the interface that the destination struct should implement to
|
|
// make a version string appear at the top of the help message.
|
|
type Appnamed interface {
|
|
// Version returns the version string that will be printed on a line by itself
|
|
// at the top of the help message.
|
|
Appname() string
|
|
}
|
|
|
|
type AutoFuncd interface {
|
|
// Version returns the version string that will be printed on a line by itself
|
|
// at the top of the help message.
|
|
DoAutoComplete(*Auto)
|
|
}
|
|
|
|
// Described is the interface that the destination struct should implement to
|
|
func newTest(tmp interface{}) {
|
|
if tmp, ok := tmp.(Appnamed); ok {
|
|
myAuto.appName = tmp.Appname()
|
|
} else {
|
|
panic("you need to make the function argv.Appname()")
|
|
}
|
|
|
|
if tmp, ok := tmp.(AutoFuncd); ok {
|
|
myAuto.autoFunc = tmp.DoAutoComplete
|
|
} else {
|
|
panic("you need to make the function argv.DoAutoComplete()")
|
|
}
|
|
}
|