new argv bash completion
This commit is contained in:
parent
8ab0924350
commit
89c9b46f8b
4
Makefile
4
Makefile
|
@ -15,6 +15,10 @@ build: goimports vet
|
|||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
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 \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
|
|
22
argv.go
22
argv.go
|
@ -9,9 +9,9 @@ package main
|
|||
*/
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.wit.com/lib/gui/prep"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
|
@ -60,17 +60,15 @@ func init() {
|
|||
handles shell autocomplete
|
||||
*/
|
||||
|
||||
func (a args) DoAutoComplete(argv []string) {
|
||||
switch argv[0] {
|
||||
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 (args) Appname() string {
|
||||
return ARGNAME
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
|
3
build
3
build
|
@ -6,3 +6,6 @@ cp gus.service files/lib/systemd/system/
|
|||
|
||||
mkdir -p files/usr/lib/gus/
|
||||
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
|
||||
|
|
11
main.go
11
main.go
|
@ -17,7 +17,6 @@ import (
|
|||
"github.com/svent/go-nbreader"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"go.wit.com/dev/alexflint/arg"
|
||||
"go.wit.com/lib/gui/prep"
|
||||
"go.wit.com/log"
|
||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
@ -33,17 +32,11 @@ var resources embed.FS
|
|||
|
||||
func main() {
|
||||
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.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 me.pp == nil {
|
||||
me.pp.WriteHelp(os.Stdout)
|
||||
os.Exit(0)
|
||||
}
|
||||
log.Info("tmp hack", uuid.New().String())
|
||||
|
||||
me = new(gusconf)
|
||||
me.pollDelay = 10 * time.Second
|
||||
|
||||
if argv.UseME {
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
sync "sync"
|
||||
"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 *gusconf
|
|||
|
||||
// this app's variables
|
||||
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
|
||||
portmaps *Portmaps // the portmap window
|
||||
portwin *stdTableWin // the portwin window
|
||||
|
|
Loading…
Reference in New Issue