diff --git a/args.go b/args.go index d4ccc9f..1ff96d2 100644 --- a/args.go +++ b/args.go @@ -2,42 +2,31 @@ package main /* this parses the command line arguements + + this enables command line options from other packages like 'gui' and 'log' */ import ( "log" - "fmt" "time" arg "github.com/alexflint/go-arg" "go.wit.com/gui" ) var args struct { - Verbose bool - VerboseNet bool `arg:"--verbose-net" help:"debug your local OS network settings"` - VerboseDNS bool `arg:"--verbose-dns" help:"debug your dns settings"` - LogFile string `help:"write all output to a file"` - // User string `arg:"env:USER"` Display string `arg:"env:DISPLAY"` - - Foo string - Bar bool - User string `arg:"env:USER"` - Demo bool `help:"run a demo"` - gui.GuiArgs + VerboseDNS bool `arg:"--verbose-dns" help:"debug your dns settings"` } func init() { arg.MustParse(&args) - fmt.Println(args.Foo, args.Bar, args.User) + // fmt.Println(args.Foo, args.Bar, args.User) - if (args.Gui != "") { - gui.GuiArg.Gui = args.Gui + if gui.ArgDebug() { + log.Println(true, "INIT() gui debug == true") + } else { + log.Println(true, "INIT() gui debug == false") } - log.Println(true, "INIT() args.GuiArg.Gui =", gui.GuiArg.Gui) - -// me.dnsTTL = 2 // how often to recheck DNS -// me.dnsTTLsleep = 0.4 // sleep between loops me.dnsSleep = 500 * time.Millisecond me.localSleep = 100 * time.Millisecond diff --git a/cloudflare/api.go b/cloudflare/api.go index 036adc7..293857f 100644 --- a/cloudflare/api.go +++ b/cloudflare/api.go @@ -2,12 +2,11 @@ package cloudflare import ( - "log" "encoding/json" "io/ioutil" "net/http" - "github.com/davecgh/go-spew/spew" + "go.wit.com/log" ) /* @@ -205,7 +204,7 @@ func GetZones(auth, email string) *DNSRecords { // log.Println("getZones() worked", records) // log.Println("spew dump:") - spew.Dump(records) + // spew.Dump(records) for _, record := range records.Result { log.Println("spew record:", record) log.Println("record:", record.Name, record.ID) diff --git a/cloudflare/mainWindow.go b/cloudflare/mainWindow.go index af5b221..064b0bd 100644 --- a/cloudflare/mainWindow.go +++ b/cloudflare/mainWindow.go @@ -6,6 +6,7 @@ import ( "log" "go.wit.com/gui" + "go.wit.com/gui/gadgets" ) // This creates a window @@ -79,8 +80,20 @@ func makeConfigWindow(n *gui.Node) { grid.NewLabel("Cloudflare API") grid.NewLabel(url) + hostname := gadgets.NewBasicEntry(grid, "hostname") + zone := gadgets.NewBasicEntry(grid, "domain name") + grid.Pad() + vb.NewButton("Lookup Hostname", func () { + log.Println("Find all the Resource Records for hostname:", hostname.Get()) + log.Println("Find all the Resource Records for zone:", zone.Get()) + GetZones(aw.S, ew.S) + for d, v := range Config { + log.Println("Zone =", d, "v =", v) + } + }) + vb.NewButton("getZones()", func () { log.Println("getZones()") GetZones(aw.S, ew.S) diff --git a/examples/control-panel-cloudflare/Makefile b/examples/control-panel-cloudflare/Makefile index 07d8f77..c5947f9 100644 --- a/examples/control-panel-cloudflare/Makefile +++ b/examples/control-panel-cloudflare/Makefile @@ -17,8 +17,11 @@ log: reset tail -f /tmp/witgui.* /tmp/guilogfile +debug: build + ./control-panel-cloudflare --gui-debug + gocui: build - ./control-panel-cloudflare -gui gocui >/tmp/witgui.log.stderr 2>&1 + ./control-panel-cloudflare --gui gocui >/tmp/witgui.log.stderr 2>&1 quiet: ./control-panel-cloudflare >/tmp/witgui.log.stderr 2>&1 diff --git a/examples/control-panel-cloudflare/argv.go b/examples/control-panel-cloudflare/argv.go index 49167cd..7bacec2 100644 --- a/examples/control-panel-cloudflare/argv.go +++ b/examples/control-panel-cloudflare/argv.go @@ -1,30 +1,17 @@ -// This creates a simple hello world window package main +/* + this enables command line options from other packages like 'gui' and 'log' +*/ + import ( - "fmt" arg "github.com/alexflint/go-arg" "go.wit.com/gui" - log "go.wit.com/gui/log" + "go.wit.com/log" ) -var args struct { - Foo string - Bar bool - User string `arg:"env:USER"` - Demo bool `help:"run a demo"` - gui.GuiArgs - log.LogArgs -} - func init() { - arg.MustParse(&args) - fmt.Println(args.Foo, args.Bar, args.User) - - if (args.Gui != "") { - gui.GuiArg.Gui = args.Gui - } - log.Log(true, "INIT() args.GuiArg.Gui =", gui.GuiArg.Gui) - + arg.MustParse() + log.Bool(true, "INIT() args.ArgDebug =", gui.ArgDebug()) } diff --git a/examples/control-panel-cloudflare/config.go b/examples/control-panel-cloudflare/config.go index a65ad25..a3cf226 100644 --- a/examples/control-panel-cloudflare/config.go +++ b/examples/control-panel-cloudflare/config.go @@ -1,4 +1,3 @@ -// This is a simple example package main import ( @@ -10,6 +9,8 @@ import ( "go.wit.com/control-panel-dns/cloudflare" ) +var configfile string = ".config/wit/cloudflare" + func saveConfig() { log.Println("TODO") } diff --git a/examples/control-panel-cloudflare/main.go b/examples/control-panel-cloudflare/main.go index 0661a93..e7ab162 100644 --- a/examples/control-panel-cloudflare/main.go +++ b/examples/control-panel-cloudflare/main.go @@ -1,26 +1,21 @@ -// This is a simple example package main import ( + "go.wit.com/log" "go.wit.com/gui" "go.wit.com/control-panel-dns/cloudflare" ) var title string = "Cloudflare DNS Control Panel" -var outfile string = "/tmp/guilogfile" -var configfile string = ".config/wit/cloudflare" var myGui *gui.Node -// var buttonCounter int = 5 -// var gridW int = 5 -// var gridH int = 3 - -// var mainWindow, more, more2 *gui.Node - // var cloudflareURL string = "https://api.cloudflare.com/client/v4/zones/" func main() { + // send all log() output to a file in /tmp + log.SetTmp() + // parse the config file readConfig() diff --git a/examples/control-panel-digitalocean/argv.go b/examples/control-panel-digitalocean/argv.go new file mode 100644 index 0000000..7bacec2 --- /dev/null +++ b/examples/control-panel-digitalocean/argv.go @@ -0,0 +1,17 @@ +package main + +/* + this enables command line options from other packages like 'gui' and 'log' +*/ + +import ( + arg "github.com/alexflint/go-arg" + "go.wit.com/gui" + "go.wit.com/log" +) + + +func init() { + arg.MustParse() + log.Bool(true, "INIT() args.ArgDebug =", gui.ArgDebug()) +}