dkorunic / iSMC

Apple SMC CLI tool that can decode and display temperature, fans, battery, power, voltage and current information
GNU General Public License v3.0
113 stars 13 forks source link

Add support for JSON output format (#8) #9

Closed roele closed 2 years ago

roele commented 2 years ago

This is a first draft to add support for multiple output formats via new output (--o) flag.

The interface Output defines groups for sensors which need to be implemented. The TableOutput and JSONOutput implement the interface. The smc package returns information in form of a map[string]interface{} for each specific group (instead of printing them directly). Finally the commands pass the output flag value into a factory method which returns the matching output on which the methods for printing are called.

dkorunic commented 2 years ago

Looks good, but let's merge this after I finish up adding M1 HID sensors support, I'm halfway there.

roele commented 2 years ago

Will keep improving the change meanwhile. I will try to add more tests etc.

DrPsychick commented 2 years ago

quickly tested @roele's branch on my M1 Air, works like a charm!