-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
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
Configurable version in usage output #193
Comments
Hey @daenney - why not just have your |
I mean, I still want to print a version. Just not where the current version is being outputted in |
Got it. That's reasonable. I think the best solution would be the ability to specify a custom template for help output, as discussed in a previous issue on the topic. In the absence of that, a workaround would be to omit the var args struct {
...
}
p, err := arg.NewParser(&args)
err = p.Parse(os.Args())
if err == arg.ErrVersion {
fmt.Println("Version: 1.2.3")
os.Exit(1)
} This still wouldn't solve your use-case of putting the version string at the bottom... |
Ah, I suppose that would work. Thanks for the pointer. Being able to supply a template to customise the usage output sounds useful. I might look into that over the weekend. |
Will add this in upcoming v2 of this library |
Right now, this library will always output the result of
Version()
at the start of the usage output:go-arg/usage.go
Lines 84 to 86 in 74af96c
From my own observations, doing this is fairly uncommon amongst the CLI utilities installed on my system, especially for those that provide a dedicated flag to retrieve the version. To me personally it also feels a little out of place. If I were going to include the version information in usage output I would probably do it in the epilogue, not in the prologue.
Would you accept a PR which makes this configurable? Something like a
func (args) VersionInHelp() bool {}
that could returnfalse
causing theVersion()
to not be emitted, or a flag onConfig
?The text was updated successfully, but these errors were encountered: