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

Add --raw/-r option to "get token" CLI commands #678

Conversation

randomir
Copy link
Member

@randomir randomir commented Nov 1, 2024

Close #598.

@randomir randomir requested a review from thisac November 1, 2024 21:49
Copy link

codecov bot commented Nov 1, 2024

Codecov Report

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

Project coverage is 89.01%. Comparing base (17049a8) to head (780ef26).
Report is 24 commits behind head on master.

Files with missing lines Patch % Lines
dwave/cloud/cli.py 95.45% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #678      +/-   ##
==========================================
+ Coverage   89.00%   89.01%   +0.01%     
==========================================
  Files          44       44              
  Lines        4803     4817      +14     
==========================================
+ Hits         4275     4288      +13     
- Misses        528      529       +1     

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

click.echo(orjson.dumps(info))
if raw_output and raw_stream.tell():
raw_stream.seek(0)
click.echo(raw_stream.read())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why use StringIO instead of just click.echo(info.get("raw")) here?

Copy link
Contributor

Choose a reason for hiding this comment

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

You could then also just have an elif instead

if raw_output:
    ...
elif json_output:
    ...

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason for using a string buffer here was to enable accumulation with output() calls and dumping all at the end in flush(), i.e. the same logic we use for JSON output. But we don't need buffering for the raw output at the moment, so sure, we can simplify the code a bit. Might go back to this implementation when/if we need buffered raw output from the CLI in the futuer.

@randomir randomir force-pushed the feature/add-raw-output-mode-to-get-token-cli/issue-598 branch from 7117b50 to 780ef26 Compare November 4, 2024 16:59
@randomir randomir merged commit e0fde11 into dwavesystems:master Nov 4, 2024
33 checks passed
@randomir randomir deleted the feature/add-raw-output-mode-to-get-token-cli/issue-598 branch November 4, 2024 17:50
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.

Add --raw/-r option to "get token" CLI commands
2 participants