oras-project / oras

OCI registry client - managing content like artifacts, images, packages
https://oras.land
Apache License 2.0
1.33k stars 160 forks source link

refactor: Handle stderr similar to stdout #1427

Closed TerryHowe closed 5 days ago

TerryHowe commented 1 week ago

What this PR does / why we need it:

Use the cmd.ErrOrStderr() for error output. This is more consistent and go scripting will be able to capture stderr.

This should be the final PR for the printer although it may be worth looking at where things are and to see what could be improved.

codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.22%. Comparing base (f8519a9) to head (f411046).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1427 +/- ## ========================================== - Coverage 85.28% 85.22% -0.06% ========================================== Files 106 106 Lines 3798 3798 ========================================== - Hits 3239 3237 -2 - Misses 334 336 +2 Partials 225 225 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

qweeah commented 1 week ago

It just came to me: If user resets command output (via SetErr) should we also set the err output stream for logging?

TerryHowe commented 6 days ago

I created and issue to investigate the logging idea. I'm not sure.

As to go scripting, I think it should work just like shell scripting. By default stdout and stderr go to the current file descriptors. If the user wants to redirect stdout or stderr, they should be allowed to do that. Currently, they can only redirect stdout.

qweeah commented 6 days ago

By default stdout and stderr go to the current file descriptors.

One tricky point is that go scripting allows running several commands in parallel, and assign each run different files for stdout and stderr. Logging should go to the user-assigned stderr (but not need to be done in this PR).

TerryHowe commented 5 days ago

Created issue https://github.com/oras-project/oras-www/issues/357