nushell/src/commands/ps.rs

20 lines
516 B
Rust
Raw Normal View History

2019-05-10 18:59:12 +02:00
use crate::errors::ShellError;
use crate::object::process::process_dict;
2019-05-16 00:23:36 +02:00
use crate::object::Value;
use crate::prelude::*;
2019-05-10 18:59:12 +02:00
use sysinfo::SystemExt;
pub fn ps(_args: CommandArgs) -> Result<OutputStream, ShellError> {
2019-05-22 09:12:03 +02:00
let mut system = sysinfo::System::new();
system.refresh_all();
2019-05-10 18:59:12 +02:00
2019-05-22 09:12:03 +02:00
let list = system.get_process_list();
2019-05-10 18:59:12 +02:00
2019-05-22 09:12:03 +02:00
let list = list
.into_iter()
.map(|(_, process)| ReturnValue::Value(Value::Object(process_dict(process))))
.collect::<VecDeque<_>>();
2019-05-10 18:59:12 +02:00
Ok(list.boxed())
2019-05-10 18:59:12 +02:00
}