diff options
| author | Jeff Carr <[email protected]> | 2025-10-25 14:50:48 -0500 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-25 14:50:48 -0500 | 
| commit | 9e5b6bebd624f86b1cc5eccf5474b9e63cd24651 (patch) | |
| tree | 49a81a60eb77488159a197ac5be22f63ecc22e3d | |
| parent | 3297ac713e589db0223fe734e0400d8e8459bdf5 (diff) | |
notsure
| -rw-r--r-- | complete.go | 7 | ||||
| -rw-r--r-- | go.mod | 8 | ||||
| -rw-r--r-- | go.sum | 12 | ||||
| -rw-r--r-- | parse.go | 10 | ||||
| -rw-r--r-- | usage.go | 12 | 
5 files changed, 34 insertions, 15 deletions
diff --git a/complete.go b/complete.go index 1c815ec..d521f73 100644 --- a/complete.go +++ b/complete.go @@ -5,6 +5,8 @@ import (  	"io"  	"os"  	"strings" + +	"go.wit.com/lib/protobuf/argvpb"  )  // has the variables for autocomplete @@ -15,6 +17,11 @@ type Complete struct {  	Stdout     io.Writer // this is where Stdout  } +func (p *Parser) WriteHelpForAutocompleteArgv() error { +	argvpb.PB.Stderr += fmt.Sprintln("go-args.WriteHelpForAutocompleteArgv() not finished") +	return nil +} +  // same as WriteHelpForSubcommand above, but can flip to STDERR and STDOUT  // most shell autocomplete behavior usually wants things that way  func (p *Parser) WriteHelpForAutocomplete(stderr io.Writer, stdout io.Writer, partial string, subcommand ...string) error { @@ -1,14 +1,14 @@  module go.wit.com/dev/alexflint/arg +go 1.24.1 +  require (  	github.com/alexflint/go-scalar v1.2.0 -	github.com/stretchr/testify v1.7.0 +	github.com/stretchr/testify v1.11.1  )  require (  	github.com/davecgh/go-spew v1.1.1 // indirect  	github.com/pmezard/go-difflib v1.0.0 // indirect -	gopkg.in/yaml.v3 v3.0.0 // indirect +	gopkg.in/yaml.v3 v3.0.1 // indirect  ) - -go 1.18 @@ -1,16 +1,12 @@  github.com/alexflint/go-scalar v1.2.0 h1:WR7JPKkeNpnYIOfHRa7ivM21aWAdHD0gEWHCx+WQBRw=  github.com/alexflint/go-scalar v1.2.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=  github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=  github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=  github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=  github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=  gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=  gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA= -gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= @@ -12,6 +12,7 @@ import (  	"strings"  	scalar "github.com/alexflint/go-scalar" +	"go.wit.com/lib/protobuf/argvpb"  )  // path represents a sequence of steps to find the output location for an @@ -125,13 +126,16 @@ func Parse(dest ...interface{}) error {  }  // pass in a "pretend" os.Args. Used for bash autocomplete -func ParseFlags(flags []string, dest ...interface{}) (*Parser, error) { +func ParseFlagsArgv(dest ...interface{}) (*Parser, error) {  	p, err := NewParser(Config{}, dest...)  	if err != nil {  		return p, err  	} -	overrideFlags = append(overrideFlags, flags...) -	err = p.Parse(flags) +	if argvpb.PB == nil { +		panic("argvpb.PB is nil") +	} +	overrideFlags = append(overrideFlags, argvpb.PB.Real...) +	err = p.Parse(argvpb.PB.Real)  	return p, err  } @@ -4,6 +4,8 @@ import (  	"fmt"  	"io"  	"strings" + +	"go.wit.com/lib/protobuf/argvpb"  )  // the width of the left column @@ -90,11 +92,21 @@ func withEnv(env string) string {  	return "env: " + env  } +func (p *Parser) WriteHelpArgv() error { +	argvpb.PB.Stderr += fmt.Sprintln("go-args.WriteHelpArgv() not finished") +	return nil +} +  // WriteHelp writes the usage string followed by the full help string for each option  func (p *Parser) WriteHelp(w io.Writer) {  	p.WriteHelpForSubcommand(w, p.subcommand...)  } +func (p *Parser) WriteHelpForSubcommandArgv() error { +	argvpb.PB.Stderr += fmt.Sprintln("go-args.WriteHelpForSubcommandArgv() not finished") +	return nil +} +  // WriteHelpForSubcommand writes the usage string followed by the full help  // string for a specified subcommand. To write help for a top-level subcommand,  // provide just the name of that subcommand. To write help for a subcommand that  | 
