diff options
| author | Jeff Carr <[email protected]> | 2025-10-26 10:48:41 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-26 10:48:41 -0500 |
| commit | 51027a1b04b3da1a81d617d16a07ac1242d90a81 (patch) | |
| tree | cecc3b9d3d1c2e9b6285117bb5ae01827b30fd22 /complete.go | |
| parent | 0653bd60ce9276ad6245b25c60f37aefd0d1408a (diff) | |
update for new argvpb changes
Diffstat (limited to 'complete.go')
| -rw-r--r-- | complete.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/complete.go b/complete.go new file mode 100644 index 0000000..b7c7a47 --- /dev/null +++ b/complete.go @@ -0,0 +1,42 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +import ( + "fmt" + "strings" + + "go.wit.com/dev/alexflint/arg" + "go.wit.com/lib/protobuf/argvpb" +) + +// sent via -ldflags +var VERSION string +var BUILDTIME string + +// used for shell auto completion +var APPNAME string = "mirrors" // todo: get this from $0 + +func (args) MustParse() error { + me.pp = arg.MustParse(&argv) + return nil +} + +// sends the strings to bash or zsh that will be your options +func (a args) DoAutoComplete() error { + if argvpb.PB.GetCmd() == "" { + matches := []string{"--dry-run", "--force", "incoming", "walk", "list", "everything", "verify", "newest", "--create", "--verbose", "release"} + fmt.Fprintf(argvpb.Stdout, " %s", strings.Join(matches, " ")) + return nil + } + var err error + if me.pp == nil { + me.pp, err = arg.ParseFlagsArgv(&argv) + if err != nil { + return err + } + } + err = me.pp.WriteHelpForAutocomplete(argvpb.PB.Partial, argvpb.PB.Real...) + return err +} |
