diff options
| author | Jeff Carr <[email protected]> | 2025-09-25 01:41:05 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-25 01:41:05 -0500 |
| commit | bb99305225210181525b1482888a7bfddd9ff68e (patch) | |
| tree | b0a9002926514e4a519463bc0b2b4bcea27d48f5 | |
| parent | 10ccaf765b25e3712b2bde2737ae443ae68284af (diff) | |
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | argv.go | 40 | ||||
| -rwxr-xr-x | build | 3 | ||||
| -rw-r--r-- | main.go | 6 | ||||
| -rw-r--r-- | structs.go | 3 |
5 files changed, 19 insertions, 35 deletions
@@ -31,7 +31,7 @@ build: goimports vet GO111MODULE=off go build -v -x \ -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" -install: +install: goimports GO111MODULE=off go install \ -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" @@ -9,9 +9,9 @@ package main */ import ( - "fmt" "os" + "go.wit.com/lib/gui/prep" "go.wit.com/log" ) @@ -63,35 +63,19 @@ func init() { WARN = log.NewFlag("WARN", true, full, short, "bad things") } -// prints help to STDERR // TODO: move everything below this to go-args -func (args) doBashHelp() { - if argv.BashAuto[1] != "''" { - // if this is not blank, then the user has typed something - return - } - if argv.BashAuto[0] != ARGNAME { - // if this is not the name of the command, the user already started doing something - return - } - if argv.BashAuto[0] == ARGNAME { - me.pp.WriteHelp(os.Stderr) - return - } +/* + handles shell autocomplete +*/ + +func (args) Appname() string { + return ARGNAME } -func (args) DoAutoComplete(argv []string) { - switch argv[0] { - case "list": - fmt.Println("") - case "verify": - fmt.Println("on") - case "upgrade": - fmt.Println("") - default: - if argv[0] == ARGNAME { - // list the subcommands here - fmt.Println("help list") - } +func (a args) DoAutoComplete(pb *prep.Auto) { + if pb.Cmd == "" { + pb.Autocomplete3([]string{"gui", "list", "--daemon"}) + } else { + pb.SubCommand(pb.Argv...) } os.Exit(0) } @@ -6,3 +6,6 @@ cp zookeeper.service files/lib/systemd/system/ mkdir -p files/usr/lib/zookeeper/ cp Makefile.help files/usr/lib/zookeeper/Makefile + +mkdir -p files/usr/share/bash-completion/completions/ +zookeeper --bash > files/usr/share/bash-completion/completions/zookeeper @@ -7,7 +7,6 @@ import ( "os" "time" - "go.wit.com/dev/alexflint/arg" "go.wit.com/lib/gui/prep" "go.wit.com/lib/protobuf/httppb" "go.wit.com/lib/protobuf/zoopb" @@ -21,9 +20,8 @@ var ARGNAME string = "zookeeper" func main() { me = new(mainType) - prep.Bash(ARGNAME, argv.DoAutoComplete) // this line should be: prep.Bash(argv) - me.myGui = prep.Gui() // prepares the GUI package for go-args - me.pp = arg.MustParse(&argv) + me.myGui = prep.Gui() // prepares the GUI package for go-args + me.auto = prep.Bash3(&argv) // add support for bash autocomplete with go-arg if argv.Daemon { // turn off timestamps for STDOUT (systemd adds them) @@ -6,7 +6,6 @@ package main import ( "time" - "go.wit.com/dev/alexflint/arg" "go.wit.com/gui" "go.wit.com/lib/gadgets" "go.wit.com/lib/gui/prep" @@ -17,7 +16,7 @@ var me *mainType // this app's variables type mainType struct { - pp *arg.Parser // for parsing the command line args. Yay to alexf lint! + auto *prep.Auto // more experiments for bash handling hostname string // my fqdn dns zookeeper hostname pollDelay time.Duration // how often to report our status dog *time.Ticker // the watchdog timer |
