diff options
| author | Jeff Carr <[email protected]> | 2025-10-26 09:34:27 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-26 09:34:27 -0500 |
| commit | d411389d0bf214fee8502ddc5f18307b2fc8f698 (patch) | |
| tree | 54698fdd1fd16143422524047e9ce7d02adb9a55 /complete.go | |
| parent | 6dc6b5c25a4a489e37529e05380fe57646a59c0c (diff) | |
Diffstat (limited to 'complete.go')
| -rw-r--r-- | complete.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/complete.go b/complete.go new file mode 100644 index 0000000..a4fab62 --- /dev/null +++ b/complete.go @@ -0,0 +1,46 @@ +package main + +import ( + "fmt" + "strings" + + "go.wit.com/lib/protobuf/argvpb" + "go.wit.com/dev/alexflint/arg" +) + +// this is where to customize argv for your application + +var APPNAME string = "basicwindow" + +// sent via -ldflags +var VERSION string +var BUILDTIME string + +func (a args) Description() string { + return ` +This basicwindow example demonstrates multiple windows +` +} + +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{"--bash", "--version", "demo", "gui"} + 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 +} |
