Skip to content

Instantly share code, notes, and snippets.

@robmiller
Last active September 23, 2015 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robmiller/ebb73393ff6d93864175 to your computer and use it in GitHub Desktop.
Save robmiller/ebb73393ff6d93864175 to your computer and use it in GitHub Desktop.
extern crate plist;
use std::process::Command;
use std::io::{Read,Seek,SeekFrom,Cursor};
use plist::StreamingParser;
fn main() {
println!("Profiling system.");
let profiler = Command::new("system_profiler")
.arg("-xml")
.arg("-detailLevel")
.arg("basic")
.output()
.unwrap_or_else(|e| { panic!("Failed to spawn system profiler: {}", e) });
let xml = String::from_utf8_lossy(&profiler.stdout).into_owned();
println!("Parsing XML.");
let mut stdout = Cursor::new(xml.into_bytes());
let parser = StreamingParser::new(stdout);
println!("Parser created.");
for event in parser {
println!("{:?}", event);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment