tanka icon indicating copy to clipboard operation
tanka copied to clipboard

`tk env list -l foo=bar` should exit with non-zero code when nothing is found

Open bcbrockway opened this issue 2 years ago • 1 comments

As per the title, it would be nice for scripting if the command tk env list -l foo=bar exited with a non-zero code when it can't find anything using the selectors you input. Same logic as for grep basically.

bcbrockway avatar Jun 30 '22 08:06 bcbrockway

The --json option allows to script that. Example:

[[ "$(tk env list --json -l foo=bar | jq length)" == 0 ]] && echo "0 results" || echo "found envs"

You can get rid of jq by testing for the brackets directly also:

[[ "$(tk env list --json -l foo=bar)" == "[]" ]] && echo "0 results" || echo "found envs"

julienduchesne avatar Sep 12 '22 01:09 julienduchesne