cobra
cobra copied to clipboard
feat: Add the `WithUsage` function.
Add a wrapper for PositionalArgs
that supplements errors with usage information.
The error messages provided by the PositionalArgs
functions is quite terse, e.g.
accepts n arg(s), received m
In many cases this will not be enough information for users to correct their mistake. The new WithUsage
function includes the usage string in the error message to improve the user experience.
Example:
cmd := &cobra.Command{
Use: "example <arg>",
Args: cobra.WithUsage(cobra.ExactArgs(1)),
}
I like this. And I like the use of an example function in the tests, which we haven’t done before. Nice job.