From 4827be1d2ab4a37fc45a31116df2f109e1a8390e Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 9 Sep 2025 02:30:38 -0500 Subject: cleaner argv autocomplete --- argv.go | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) (limited to 'argv.go') diff --git a/argv.go b/argv.go index 500229e..a203c8e 100644 --- a/argv.go +++ b/argv.go @@ -25,8 +25,6 @@ type args struct { Daemon bool `arg:"--daemon" help:"run as a daemon"` Force bool `arg:"--force" help:"try to strong arm things"` Verbose bool `arg:"--verbose" help:"show more output"` - Bash bool `arg:"--bash" help:"generate bash completion"` - BashAuto []string `arg:"--auto-complete" help:"todo: move this to go-arg"` } type EmptyCmd struct { @@ -40,37 +38,13 @@ func init() { arg.MustParse(&argv) } -// prints help to STDERR // TODO: move everything below this to go-args -func (args) doBashHelp() { - if len(argv.BashAuto) < 2 { - fmt.Fprintf(os.Stderr, "something went wrong with the GO args autocomplete in %s\n", ARGNAME) - return - } - if argv.BashAuto[1] != "''" { - // if this is not blank, then the user has typed something - return - } - if argv.BashAuto[0] != ARGNAME { - fmt.Fprintln(os.Stderr, argv.BashAuto[0]) - // if this is not the name of the command, the user already started doing something - return - } - if argv.BashAuto[0] == ARGNAME { - me.pp.WriteHelp(os.Stderr) - return - } - fmt.Fprintln(os.Stderr, "") - fmt.Fprintln(os.Stderr, "something went wrong with the GO args package") - fmt.Fprintln(os.Stderr, "") -} - -func (args) doBashAuto() { +func (a args) DoAutoComplete(argv []string) { // argv.doBashHelp() - switch argv.BashAuto[0] { + switch argv[0] { case "merge": fmt.Println("--force") default: - if argv.BashAuto[0] == ARGNAME { + if argv[0] == ARGNAME { // list the subcommands here fmt.Println("list merge") } -- cgit v1.2.3