cmd/build: return error if there is more than one positional argument
Before, this would only return an error if there was no query argument.
However, I've run into this recently, running the erroneous command
opa build -o out.wasm 'data.simplest.allow = x' simplest.rego
which produced no error, the resulting wasm file wasn't what I was
expecting.
With this change, the bad command line would give an error; and might
prompt the user to re-read the usage text and provide the proper command
instead,
opa build -o out.wasm -d simplest.rego 'data.simplest.allow = x'
----
Alternatively to how it's done here, we could have provided the cobra
field
Args: cobra.ExactArgs(1),
but the PreRunE function has a more specific error message. So, I've
taken the message from `opa deps`.
Signed-off-by: Stephan Renatus <srenatus@chef.io> S
Stephan Renatus committed
6f646b7a79648c3ff9ce5eda3d58a6cb304412f9
Parent: 54861cd
Committed by Torin Sandall <torinsandall@gmail.com>
on 1/7/2020, 10:49:10 PM