Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Handle stderr similar to stdout #1427

Merged
merged 1 commit into from
Jun 26, 2024
Merged

Conversation

TerryHowe
Copy link
Member

@TerryHowe TerryHowe commented Jun 22, 2024

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.

Copy link

codecov bot commented Jun 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@            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              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@qweeah
Copy link
Contributor

qweeah commented Jun 24, 2024

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

@TerryHowe
Copy link
Member Author

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
Copy link
Contributor

qweeah commented Jun 25, 2024

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
Copy link
Member Author

Created issue oras-project/oras-www#357

Copy link
Contributor

@qweeah qweeah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM though some printer are already imbedded in command options and no need to recreate. Will change that in another PR.

cmd/oras/root/discover.go Show resolved Hide resolved
@qweeah qweeah merged commit 46de891 into oras-project:main Jun 26, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants