We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello, thanks a lot for go-arg, I love it!
consider the following program (using go-arg v1.1.0)
package main import ( "fmt" arg "github.com/alexflint/go-arg" ) func main() { var args struct { Foo []string A string `arg:"positional,required"` } arg.MustParse(&args) fmt.Printf("%+v\n", args) }
Let's ask for its help:
$ ./bin/positional -h Usage: positional [--foo FOO] A Positional arguments: A Options: --foo FOO --help, -h display this help and exit
If I try to follow the "Usage" example, I get:
$ ./bin/positional --foo 1 x Usage: positional [--foo FOO] A error: a is required
which is very confusing for the end user (and at first for the programmer too, then the programmer understands the reason :-D)
After thinking about it, I tried the classic -- to mean end of flag processing, but it didn't work:
--
$ ./bin/positional --foo 1 -- x Usage: positional [--foo FOO] A error: a is required
After a while I saw the light and inverted the order, and it worked as expected:
$ ./bin/positional x --foo 1 {Foo:[1] A:x}
So I guess I have two questions:
Usage: positional A [--foo FOO]
or any other way to give an hint to the user?
The text was updated successfully, but these errors were encountered:
Woah this is definitely a bug. Both of the examples you gave are supposed to work:
./bin/positional --foo 1 x ./bin/positional --foo 1 -- x
If these are broken then go-arg has a regression in a recent release. I'll investigate.
Sorry, something went wrong.
Oh on first read I didn't see that foo is a []string. Given that, I still expect the second example you gave to work (but not the first):
[]string
./bin/positional --foo 1 -- x // is supposed to work given the program you gave ./bin/positional --foo 1 x // not expected to work
Would it make sense then to change the usage text to mention the -- if the positional is required? Maybe:
Usage: positional [--foo FOO --] A
Successfully merging a pull request may close this issue.
Hello, thanks a lot for go-arg, I love it!
consider the following program (using go-arg v1.1.0)
Let's ask for its help:
If I try to follow the "Usage" example, I get:
which is very confusing for the end user (and at first for the programmer too, then the programmer understands the reason :-D)
After thinking about it, I tried the classic
--
to mean end of flag processing, but it didn't work:After a while I saw the light and inverted the order, and it worked as expected:
So I guess I have two questions:
--
trick work? (Is this maybe a regression of Positional arguments with dashes #55 ?)or any other way to give an hint to the user?
The text was updated successfully, but these errors were encountered: