Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Option to suppress normal output #2230

Open
fearphage opened this issue Dec 13, 2024 · 0 comments
Open

Feature request: Option to suppress normal output #2230

fearphage opened this issue Dec 13, 2024 · 0 comments

Comments

@fearphage
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant