nu 0.1.2

A shell for the GitHub era
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::errors::ShellError;
use crate::object::process::process_dict;
use crate::prelude::*;
use sysinfo::{RefreshKind, SystemExt};

pub fn ps(args: CommandArgs) -> Result<OutputStream, ShellError> {
    let mut system = sysinfo::System::new_with_specifics(RefreshKind::new().with_processes());
    system.refresh_processes();
    let list = system.get_process_list();

    let list = list
        .into_iter()
        .map(|(_, process)| process_dict(process, args.name_span))
        .collect::<VecDeque<_>>();

    Ok(list.from_input_stream())
}