summaryrefslogtreecommitdiff
path: root/args.go
blob: b521e42c76a71ee0e600e46c0ef2bd2aff27769e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main

/*
	this parses the command line arguements

	this enables command line options from other packages like 'gui' and 'log'
*/

import 	(
	"time"
	arg "github.com/alexflint/go-arg"
	"go.wit.com/log"
	"go.wit.com/gui/debugger"
)

var args struct {
	Display string `arg:"env:DISPLAY"`
	TmpLog bool  `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"`
	VerboseDNS bool  `arg:"--verbose-dns" help:"debug your dns settings"`
}

var NOW log.LogFlag
var INFO log.LogFlag
var NET log.LogFlag
var DNS log.LogFlag

var WARN log.LogFlag
var SPEW log.LogFlag

var CHANGE log.LogFlag
var STATUS log.LogFlag

func init() {
	arg.MustParse(&args)
	full := "go.wit.com/control-panels/dns"
	short := "cpdns"

	NOW.NewFlag( "NOW",  true,  full, short, "temp debugging stuff")
	INFO.NewFlag("INFO", false, full, short, "normal debugging stuff")
	NET.NewFlag( "NET",  false, full, short, "Network logging")
	DNS.NewFlag( "DNS",  false, full, short, "dnsStatus.update()")

	WARN.NewFlag("WARN", true,  full, short, "bad things")
	SPEW.NewFlag("SPEW", false, full, short, "spew stuff")

	CHANGE.NewFlag("CHANGE", true,  full, short, "when host or dns change")
	STATUS.NewFlag("STATUS", false, full, short, "updateStatus() polling")

	if debugger.ArgDebug() {
		log.Log(NOW, "INIT() gui debug == true")
	} else {
		log.Log(NOW, "INIT() gui debug == false")
	}

	me.dnsSleep = 500 * time.Millisecond
	me.localSleep = 100 * time.Millisecond

	me.artificialSleep = 0.4	// seems to need to exist or GTK crashes. TODO: fix andlabs plugin
	me.artificialS = "blah"
	log.Log(INFO, "init() me.artificialSleep =", me.artificialSleep)
	log.Log(INFO, "init() me.artificialS =", me.artificialS)
	log.Sleep(me.artificialSleep)
}