Feature request: Option to suppress normal output #2230
Description
Please describe your feature request.
I quite often want to confirm the existence or absence of certain data in a file. For that purpse, I use yq --exit-status
to convey that information. When using that flag, it is most commonly the only output I require. So I end up writing yq --exit-status ... &> /dev/null
to throw away the extraneous output. It would be convenient if I didn't have to work around the unwanted output from the CLI and I could explicitly suppress it instead.
Just as an example:
function contains-key {
yq --exit-status "$1" "$2" &> /dev/null
}
if contains-key '.catpants' 'my/file.txt'; then
# do the needful
fi
Describe the solution you'd like
I'd like to see a new flag that doesn't require work arounds to keep the console/output clean.
A few implementation thoughts:
Additional flags to be combined with --exit-status
:
--quiet
--silent
--suppress-output
- a bit more verbose but very explicit
A different approach - an alternate (replacement?) flag:
--exit-status-only
This could theoretically allow you to deprecate--exit-status
in favor of this one. I'm honestly not sure if people are using both outputs at once. Or it could simply be remain a nice alternative.
Additional context
With this option, there'd be no need to pipe output to /dev/null
. For reference, this is similar to the grep
option:
✗ grep --help | grep quiet
-q, --quiet, --silent suppress all normal output