new argv bash completion

This commit is contained in:
Jeff Carr 2025-09-25 02:40:24 -05:00
parent 8ab0924350
commit 89c9b46f8b
5 changed files with 20 additions and 23 deletions

View File

@ -15,6 +15,10 @@ build: goimports vet
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
install: goimports vet install: goimports vet
GO111MODULE=off go install \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
install-verbose: goimports vet
GO111MODULE=off go install -v -x \ GO111MODULE=off go install -v -x \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"

20
argv.go
View File

@ -9,9 +9,9 @@ package main
*/ */
import ( import (
"fmt"
"os" "os"
"go.wit.com/lib/gui/prep"
"go.wit.com/log" "go.wit.com/log"
) )
@ -60,17 +60,15 @@ func init() {
handles shell autocomplete handles shell autocomplete
*/ */
func (a args) DoAutoComplete(argv []string) { func (args) Appname() string {
switch argv[0] { return ARGNAME
case "playback":
fmt.Println("long --uuid purge last submit")
case "clean":
fmt.Println("")
default:
if argv[0] == ARGNAME {
// list the subcommands here
fmt.Println("--json interact playback clean")
} }
func (a args) DoAutoComplete(pb *prep.Auto) {
if pb.Cmd == "" {
pb.Autocomplete3([]string{"--bash", "--me", "gui", "--daemon"})
} else {
pb.SubCommand(pb.Argv...)
} }
os.Exit(0) os.Exit(0)
} }

3
build
View File

@ -6,3 +6,6 @@ cp gus.service files/lib/systemd/system/
mkdir -p files/usr/lib/gus/ mkdir -p files/usr/lib/gus/
cp Makefile.help files/usr/lib/gus/Makefile cp Makefile.help files/usr/lib/gus/Makefile
mkdir -p files/usr/share/bash-completion/completions/
gus --bash > files/usr/share/bash-completion/completions/gus

View File

@ -17,7 +17,6 @@ import (
"github.com/svent/go-nbreader" "github.com/svent/go-nbreader"
"github.com/google/uuid" "github.com/google/uuid"
"go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/gui/prep" "go.wit.com/lib/gui/prep"
"go.wit.com/log" "go.wit.com/log"
timestamppb "google.golang.org/protobuf/types/known/timestamppb" timestamppb "google.golang.org/protobuf/types/known/timestamppb"
@ -33,17 +32,11 @@ var resources embed.FS
func main() { func main() {
me = new(gusconf) me = new(gusconf)
prep.Bash(ARGNAME, argv.DoAutoComplete) // this line should be: prep.Bash(argv)
me.myGui = prep.Gui() // prepares the GUI package for go-args me.myGui = prep.Gui() // prepares the GUI package for go-args
me.pp = arg.MustParse(&argv) me.auto = prep.Bash3(&argv) // add support for bash autocomplete with go-arg
if me.pp == nil {
me.pp.WriteHelp(os.Stdout)
os.Exit(0)
}
log.Info("tmp hack", uuid.New().String()) log.Info("tmp hack", uuid.New().String())
me = new(gusconf)
me.pollDelay = 10 * time.Second me.pollDelay = 10 * time.Second
if argv.UseME { if argv.UseME {

View File

@ -7,7 +7,6 @@ import (
sync "sync" sync "sync"
"time" "time"
"go.wit.com/dev/alexflint/arg"
"go.wit.com/gui" "go.wit.com/gui"
"go.wit.com/lib/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/prep" "go.wit.com/lib/gui/prep"
@ -17,7 +16,7 @@ var me *gusconf
// this app's variables // this app's variables
type gusconf struct { type gusconf struct {
pp *arg.Parser // for parsing the command line args. Yay to alexf lint! auto *prep.Auto // more experiments for bash handling
myGui *prep.GuiPrep // the base of the gui myGui *prep.GuiPrep // the base of the gui
portmaps *Portmaps // the portmap window portmaps *Portmaps // the portmap window
portwin *stdTableWin // the portwin window portwin *stdTableWin // the portwin window