-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Cli: enable json output #9478
Cli: enable json output #9478
Conversation
bc3dc8b
to
dc69d02
Compare
dc69d02
to
25aef38
Compare
@mvines , I would love your feedback on this approach. It's quite a bit of churn, but seems reasonably maintainable, given all the special-case printing going on in the cli. |
Codecov Report
@@ Coverage Diff @@
## master #9478 +/- ##
========================================
- Coverage 81.2% 80.7% -0.5%
========================================
Files 277 278 +1
Lines 62413 62751 +338
========================================
+ Hits 50682 50683 +1
- Misses 11731 12068 +337 |
This approach looks great. I like that we'll be able to more easily unit test the business logic of each command now as well. Probably want to get this landed ASAP to avoid rebase hell. I'd backport to v1.1 to keep us sane through the end of May, but skip the v1.0 backport since that'll only live for another couple weeks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Should be pretty easy to maintain 🙏
All I've got is a feature request 🙂
automerge (cherry picked from commit 5298e38) # Conflicts: # Cargo.lock # cli/Cargo.toml # cli/src/lib.rs # cli/src/stake.rs
automerge (cherry picked from commit 5298e38)
Problem
Some of the cli commands do a lot of client-side processing that make them valuable for users, but the displays are geared toward human eyes only. It is very difficult to ingest this data programmatically.
Summary of Changes
--output
format arg, to set OutputFormat -- currently supportsDisplay
(default) andJson
As a result, once the struct is populated, output format-selection and printing is triggered with a single line:
OutputFormat.formatted_print(&<STRUCT>);
Fixes #7827