diff options
| author | Jeff Carr <[email protected]> | 2025-10-26 10:06:03 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-26 10:06:03 -0500 |
| commit | 16fdee4c38c13bb71f1c77c15e3f9b8853bf694d (patch) | |
| tree | 9474fa59cefaacdfa8df17e19da914c9fa71884f /complete.go | |
| parent | f324a650ce0dd8298be4a81acadd107a62d059b2 (diff) | |
new argv (much better than before)v0.22.170
Diffstat (limited to 'complete.go')
| -rw-r--r-- | complete.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/complete.go b/complete.go new file mode 100644 index 0000000..9edbbc1 --- /dev/null +++ b/complete.go @@ -0,0 +1,58 @@ +package main + +import ( + "fmt" + "strings" + + "go.wit.com/dev/alexflint/arg" + "go.wit.com/lib/protobuf/argvpb" +) + +// sent from -ldflags +var VERSION string +var BUILDTIME string + +var APPNAME string = "go-deb" + +/* + this parses the command line arguements + + this enables command line options from other packages like 'gui' and 'log' +*/ + +func (args) Examples() string { + var out string + out += "go-deb --dir ~/incoming/ --repo . # build a .deb of the current directory\n" + return out +} + +func (a args) Description() string { + return ` +Example usage: + go-deb --repo go.wit.com/apps/go-clone + +this is a work in progress` +} + +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{"dump", "gui", "show", "--version", "--keep-files", "--buildversion"} + 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 +} |
