Previously, we were inconsistent on how we handled argument validation in the CLI. Many commands used cobra.Command's Args property to provide a validator if they took arguments, but commands which did not rarely used cobra.NoArgs to indicate this. This change does two things: 1. Introduce `cmdutil.ArgsFunc` which works like `cmdutil.RunFunc`, it wraps an existing cobra type and lets us control the behavior when an arguments validator fails. 2. Ensure every command sets the Args property with an instance of cmdutil.ArgsFunc. The cmdutil package defines wrapers for all the cobra validators we are using, to prevent us from having to spell out `cmduitl.ArgsFunc(...)` everywhere. Fixes #588 |
||
---|---|---|
.. | ||
args.go | ||
child.go | ||
child_windows.go | ||
diag.go | ||
exit.go | ||
log.go | ||
log_test.go | ||
trace.go |