redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

Lint output to standard out instead of standard error

Open ikenna opened this issue 8 months ago • 2 comments

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

ikenna avatar Dec 13 '23 12:12 ikenna

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.

lornajane avatar Dec 18 '23 12:12 lornajane

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

  • codeframe uses stderr
  • json uses stdout
  • checkstyle uses stdout
  • stylish uses 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

marianobntz avatar Apr 24 '24 21:04 marianobntz