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

feat(cli/unstable): support stderr on spinner #6350

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

andrewthauer
Copy link
Contributor

@andrewthauer andrewthauer commented Jan 18, 2025

Related to #5495

Adds support to the @std/cli/unstable_spinner to write to stderr instead of the default stdout.

The current Spinner is unusable when piping to another command (e.g. deno_cli | less for paging). and will cause garbled data to the pipe/console. Using stderr is the standard approach for informational text since by default it is not passed along to the piped commands stdin.

NOTE: I personally would be happy to make this the default. I'm curious if folks would be open to this considering it's currently unstable.

An alternative could be to check if the terminal is interactive or not and change the default based on this.

@andrewthauer andrewthauer requested a review from kt3k as a code owner January 18, 2025 21:05
@github-actions github-actions bot added the cli label Jan 18, 2025
@andrewthauer andrewthauer changed the title chore(cli): support stderr on spinner feat(cli): support stderr on spinner Jan 18, 2025
Copy link

codecov bot commented Jan 18, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.34%. Comparing base (5af091b) to head (364e4a3).

Files with missing lines Patch % Lines
cli/unstable_spinner.ts 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6350      +/-   ##
==========================================
+ Coverage   96.33%   96.34%   +0.01%     
==========================================
  Files         552      552              
  Lines       41938    41940       +2     
  Branches     6354     6355       +1     
==========================================
+ Hits        40399    40406       +7     
+ Misses       1499     1494       -5     
  Partials       40       40              

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

@kt3k kt3k changed the title feat(cli): support stderr on spinner feat(cli/unstable): support stderr on spinner Jan 20, 2025
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

Looks reasonable addition to me.

Can you also add an example of passing Deno.stderr in Spinner class jsdoc?

@andrewthauer
Copy link
Contributor Author

@kt3k - Updated example. I'm curious if you have an opinions or there is a standard name to use for the stream option?

Also any thoughts on making this the default vs stdout? From my perspective there aren't many or any downsides and only upsides to having this as the default. I've noticed other libraries already conform to the pattern of using stderr for informational things (e.g. dax, cliffy).

cli/unstable_spinner.ts Outdated Show resolved Hide resolved
@github-actions github-actions bot added the async label Jan 21, 2025
@kt3k
Copy link
Member

kt3k commented Jan 21, 2025

I'm curious if you have an opinions or there is a standard name to use for the stream option?

I don't think there's standard name for it, but how about output as it doesn't accept arbitrary stream?

Also any thoughts on making this the default vs stdout? From my perspective there aren't many or any downsides and only upsides to having this as the default. I've noticed other libraries already conform to the pattern of using stderr for informational things (e.g. dax, cliffy).

That sounds reasonable to me. Let's continue on that change after this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants