Redocly / redocly-cli

⚒️ Redocly CLI makes OpenAPI easy. Lint/validate to any standard, generate beautiful docs, and more.
https://redocly.com/docs/cli/
MIT License
909 stars 138 forks source link

Lint output to standard out instead of standard error #1355

Open ikenna opened 9 months ago

ikenna commented 9 months ago

Is your feature request related to a problem? Please describe.

It appears to me that linting output goes to standard error instead of standard out. redocly lint api.yaml --format stylish > lint.log cat lint.log. # Empty redocly lint api.yaml --format stylish 2> lint.log cat lint.log. # Has linting output This means I can't grep the linting output from standard out like below: redocly lint api.yaml --format stylish | grep error # Doesn't work Instead, I need to redirect standard error to standard out first: redocly lint api.yaml --format stylish 2>&1 | grep error # Works

Describe the solution you'd like Would it make sense to send the linting output to standard out instead, to enable grep and other command chaining to happen without redirecting std error ? It would be good for this to work: redocly lint api.yaml --format stylish | grep error

Describe alternatives you've considered

Additional context

lornajane commented 9 months ago

Thanks for this suggestion! We have the lint output going to stderr because we historically had commands that did multiple things and this supported that use case, where something else was output to stdout.

We need a plan for how to manage the backwards compatibility of a change like this, but I agree that the output of linting should go to stdout from the lint command.

marianobntz commented 5 months ago

Hello, it is weird, in version 1.11.0... some formats send output to stdout and others to stderr...

The problem is that we cannot split progress messages from the format itself... 😞

In any case, if you add an option to output the lint result to a file it would help with backward compatibility... No need to change the behaviour if the output file is not specified 😄

Thanks