diff options
| -rw-r--r-- | argv.go | 28 | ||||
| -rwxr-xr-x | build | 3 | ||||
| -rw-r--r-- | main.go | 11 | ||||
| -rw-r--r-- | structs.go | 3 |
4 files changed, 16 insertions, 29 deletions
@@ -1,9 +1,9 @@ package main import ( - "fmt" "os" + "go.wit.com/lib/gui/prep" "go.wit.com/log" ) @@ -84,23 +84,15 @@ func init() { handles shell autocomplete */ -func (a args) DoAutoComplete(argv []string) { - switch argv[0] { - case "list": - fmt.Println("droplets hypervisors") - case "droplet": - fmt.Println("start stop") - case "devel": - fmt.Println("--force") - case "master": - fmt.Println("") - case "verify": - fmt.Println("user devel master") - default: - if argv[0] == ARGNAME { - // list the subcommands here - fmt.Println("--bash list droplet") - } +func (args) Appname() string { + return ARGNAME +} + +func (a args) DoAutoComplete(pb *prep.Auto) { + if pb.Cmd == "" { + pb.Autocomplete3([]string{"--bash", "list", "droplet"}) + } else { + pb.SubCommand(pb.Argv...) } os.Exit(0) } @@ -3,3 +3,6 @@ # this is the systemd control file mkdir -p files/usr/bin/ cp ../virtigoctl/virtigoctl files/usr/bin/ + +mkdir -p files/usr/share/bash-completion/completions/ +virtigo --bash > files/usr/share/bash-completion/completions/virtigo @@ -9,7 +9,6 @@ import ( "path/filepath" "github.com/google/uuid" - "go.wit.com/dev/alexflint/arg" "go.wit.com/lib/gui/prep" "go.wit.com/lib/protobuf/virtpb" "go.wit.com/log" @@ -26,14 +25,8 @@ var resources embed.FS func main() { me = new(virtigoT) - 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) - - if me.pp == nil { - me.pp.WriteHelp(os.Stdout) - os.Exit(0) - } + 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 os.Getenv("VIRTIGO_HOME") == "" { homeDir, _ := os.UserHomeDir() @@ -4,7 +4,6 @@ import ( "net/url" "time" - "go.wit.com/dev/alexflint/arg" "go.wit.com/gui" "go.wit.com/lib/gadgets" "go.wit.com/lib/gui/prep" @@ -25,7 +24,7 @@ func (b *virtigoT) Enable() { // this app's variables type virtigoT struct { - pp *arg.Parser // go-arg parser + auto *prep.Auto // more experiments for bash handling myGui *prep.GuiPrep // the gui toolkit handle e *virtpb.Events // virt protobuf events hmap map[*virtpb.Hypervisor]*HyperT // map to the local struct |
