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

Set cobra default output to stdout #599

Merged
merged 1 commit into from
Aug 6, 2023
Merged

Conversation

blurfx
Copy link
Member

@blurfx blurfx commented Aug 5, 2023

What this PR does / why we need it:

Fixes an issue that could not pipe output from the Yorkie CLI

Which issue(s) this PR fixes:

Fixes #490

Special notes for your reviewer:

cobra prints output to os.Stderr by default when calling the Print function internally. See https://github.com/spf13/cobra/blob/v1.7.0/command.go#L1349-L1351

So we can pipe the results if we explicitly tell it to output to Stdout like:

$ ./yorkie project ls --rpc-addr "api.yorkie.dev:443" | wc -l
2

$ ./yorkie project ls --rpc-addr "api.yorkie.dev:443" | awk 'NR>1 {print $1}'
myProject

Does this PR introduce a user-facing change?:


Additional documentation:


Checklist:

  • Added relevant tests or not required
  • Didn't break anything

@codecov
Copy link

codecov bot commented Aug 5, 2023

Codecov Report

Merging #599 (345f105) into main (7f39f2f) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #599   +/-   ##
=======================================
  Coverage   51.45%   51.45%           
=======================================
  Files          66       66           
  Lines        6977     6977           
=======================================
  Hits         3590     3590           
  Misses       2911     2911           
  Partials      476      476           

@hackerwins hackerwins changed the title feat: set cobra default output to stdout Set cobra default output to stdout Aug 6, 2023
@hackerwins hackerwins self-requested a review August 6, 2023 02:26
Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution.

@hackerwins hackerwins merged commit d516183 into yorkie-team:main Aug 6, 2023
1 check passed
@blurfx blurfx deleted the feat/pipe branch August 6, 2023 06:53
Wu22e pushed a commit to Wu22e/yorkie that referenced this pull request Sep 3, 2023
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.

Working in Linux pipe for yorkie CLI
2 participants