Skip to content

refactor: Handle stderr similar to stdout#1427

Merged
qweeah merged 1 commit into
oras-project:mainfrom
TerryHowe:stderr
Jun 26, 2024
Merged

refactor: Handle stderr similar to stdout#1427
qweeah merged 1 commit into
oras-project:mainfrom
TerryHowe:stderr

Conversation

@TerryHowe

@TerryHowe TerryHowe commented Jun 22, 2024

Copy link
Copy Markdown
Member

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

codecov Bot commented Jun 22, 2024

Copy link
Copy Markdown

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.

Comment thread cmd/oras/internal/output/print.go
@qweeah

qweeah commented Jun 24, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

qweeah commented Jun 25, 2024

Copy link
Copy Markdown
Contributor

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).

Signed-off-by: Terry Howe <terrylhowe@gmail.com>
@TerryHowe

Copy link
Copy Markdown
Member Author

Created issue oras-project/oras-www#357

@qweeah qweeah left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread cmd/oras/root/discover.go
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