lscpu: Support extracting and outputting nested fields#218
lscpu: Support extracting and outputting nested fields#218cakebaker merged 10 commits intouutils:mainfrom
lscpu: Support extracting and outputting nested fields#218Conversation
fa54f64 to
9e1b825
Compare
lscpu: Add support for nested fields in outputlscpu: Support extracting and outputting nested fields
cakebaker
left a comment
There was a problem hiding this comment.
The rest looks good. Some tests would be nice ;-)
2e924fd to
95d57eb
Compare
Thanks for the review. Moved the code around a bit as you suggested, and added a basic test for non-JSON output. One thing to note is that with these changes, I've gone ahead and added flags to the tests so they only get executed on Linux builds. Let me know if you have better ideas for a long-term approach 🙂 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #218 +/- ##
===========================
===========================
☔ View full report in Codecov by Sentry. |
|
Thanks!
The long-term approach is probably to use a crate like |
lscpushould be capable of outputting nested information. When using human-readable output this is achieved simply using indentation, where as in JSON mode nested fields go under thechildrenproperty.Core changes:
CpuInfoto be a recursive structure, allowing for nesting of entries through thechildrenproperty./proc/cpuinfo, using a dynamically constructed Regex.-Jshorthand counterpart to the--jsonoption.Output: