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}"
|
-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}"
|
||||||
|
|
||||||
|
|
22
argv.go
22
argv.go
|
@ -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":
|
func (a args) DoAutoComplete(pb *prep.Auto) {
|
||||||
fmt.Println("")
|
if pb.Cmd == "" {
|
||||||
default:
|
pb.Autocomplete3([]string{"--bash", "--me", "gui", "--daemon"})
|
||||||
if argv[0] == ARGNAME {
|
} else {
|
||||||
// list the subcommands here
|
pb.SubCommand(pb.Argv...)
|
||||||
fmt.Println("--json interact playback clean")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
3
build
3
build
|
@ -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
|
||||||
|
|
9
main.go
9
main.go
|
@ -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 {
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue