corectl icon indicating copy to clipboard operation
corectl copied to clipboard

Display error when passing invalid flags

Open carlioth opened this issue 5 years ago • 2 comments

If I pass an invalid flag like this: corectl -c corectlconf.yaml eval "Count([Name/Alias])" --traffic --json --json is invalid.

This will then return the same value as this command: corectl -c corectlconf.yaml eval "Count([Name/Alias])" In my conf file I've specified engine, header and app.

carlioth avatar Aug 30 '19 09:08 carlioth

Actually --json is a global flag and can be passed to all commands, so it is still a valid flag for the eval command. However there is not any json output defined for the eval command hence the flag is just silently ignored.

From the help: --json Returns output in JSON format if possible, disables verbose and traffic output

wennmo avatar Aug 30 '19 13:08 wennmo

We could add the json flag only for the commands that are applicable, which would render in an error if passed to a command not supporting json output.

wennmo avatar Aug 30 '19 13:08 wennmo