summaryrefslogtreecommitdiff
path: root/theMagicOfAutocomplete.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-18 05:10:17 -0500
committerJeff Carr <[email protected]>2025-10-18 05:10:17 -0500
commit8d1a704d6f41b5f08aabc276d1476266f51c5b63 (patch)
tree46c6f81796b9ef351976debf2d8fe216fff56962 /theMagicOfAutocomplete.go
parent7ef1d9192c366423f5e6bf2b68946aac5cdea336 (diff)
move go-args back to the application code
Diffstat (limited to 'theMagicOfAutocomplete.go')
-rw-r--r--theMagicOfAutocomplete.go33
1 files changed, 19 insertions, 14 deletions
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go
index f49cd61..8030feb 100644
--- a/theMagicOfAutocomplete.go
+++ b/theMagicOfAutocomplete.go
@@ -9,8 +9,8 @@ import (
"strings"
"time"
- "go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/config"
+ "go.wit.com/log"
durationpb "google.golang.org/protobuf/types/known/durationpb"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
)
@@ -50,13 +50,12 @@ func Autocomplete(dest any) *Argv {
me.pb.Ctime = timestamppb.New(now)
// try to register bash args for go-args
- arg.Register(&ArgvBash)
- // arg.Register(&argGui)
+ // arg.Register(&ArgvBash)
// user is trying to setup bash or zsh autocomplete
// --bash or --zsh is the first os.Args
if me.pb.SetupAuto {
- // --bash was passed. try to configure bash-completion
+ // --bash or --zsh was passed. try to configure bash-completion
MakeAutocompleteFiles(me.ARGNAME)
// never forget to run this our you will hate yourself and the choices you have made
os.Exit(0)
@@ -68,8 +67,8 @@ func Autocomplete(dest any) *Argv {
all.Clone(me.pb)
errors.Join(err, all.Save())
- me.pp = arg.MustParse(dest)
- me.err = err
+ // me.pp = arg.MustParse(dest)
+ me.err = me.mustParseFunc()
return me.pb
}
@@ -130,7 +129,11 @@ func Autocomplete(dest any) *Argv {
}
// use go-args to parse the structs so we can use them here
- me.pp, err = arg.ParseFlags(flags, dest)
+ // me.pp, err = arg.ParseFlags(flags, dest)
+ if err := me.parseFlags(flags); err != nil {
+ log.Info("application parseFlags() err", err)
+ panic("argv.parseFlags() err")
+ }
if len(flags) == 0 {
// error is normal if there are no command line args
} else {
@@ -140,11 +143,11 @@ func Autocomplete(dest any) *Argv {
}
}
- if me.pp == nil {
- me.pb.Debugf("DEBUG: me.pp == nil after ParseFlags()")
- } else {
- // me.pb.Debugf("DEBUG: me.pp is ok after ParseFlags()")
- }
+ // if me.pp == nil {
+ // me.pb.Debugf("DEBUG: me.pp == nil after ParseFlags()")
+ // } else {
+ // me.pb.Debugf("DEBUG: me.pp is ok after ParseFlags()")
+ // }
// save now. this is near the end probably
all.Clone(me.pb)
@@ -165,9 +168,11 @@ func Autocomplete(dest any) *Argv {
} else {
// this means the user is pressing tab. no longer doing stderr
if me.pb.Cmd == "" {
- me.pp.WriteHelp(os.Stderr)
+ // me.pp.WriteHelp(os.Stderr)
+ me.writeHelp()
} else {
- me.pp.WriteHelpForSubcommand(os.Stderr, me.pb.Cmd)
+ // me.pp.WriteHelpForSubcommand(os.Stderr, me.pb.Cmd)
+ me.writeHelpForSubcommand(me.pb.Cmd)
}
}
} else {