openfga / cli

A cross-platform CLI to interact with an OpenFGA server
https://openfga.dev
Apache License 2.0
50 stars 25 forks source link

`fga model test --verbose` output should be easy to parse #385

Open jmickeyd opened 2 months ago

jmickeyd commented 2 months ago

Currently when running tests with the --verbose flag, a nicely parsable json is immediately followed by the plain text summary, making the whole thing harder to parse.

Example:

$ fga model test --verbose --tests tests.fga.yaml | jq .
[ json blob ... ]
jq: parse error: Invalid numeric literal at line 2, column 2

Either one of the blobs should be send to stderr, the pretty print text should be suppressed, or at a minimum, a flag be added to optionally suppress the pretty print.

jmickeyd commented 2 months ago

I'm willing to send a patch, it should be trivially small, but I'm not sure what you consider a breaking change for things like this. I.e. is the last option (adding a new flag) the preferable one?

jmickeyd commented 2 months ago

Actually, it looks like due to an effort to set the exit code correctly, the pretty print is already suppressed when there are test failures, https://github.com/openfga/cli/blob/36091f018e411c91adde357d526afa2d484bbe9a/cmd/model/test.go#L77-L79

Siddhant-K-code commented 1 month ago

I've introduced a new flag suppress-summary & raised #407