mirror of
https://github.com/nushell/nushell
synced 2025-01-14 14:14:13 +00:00
Fix unwrap
This commit is contained in:
parent
60bfa277d0
commit
c3abb3b687
1 changed files with 11 additions and 11 deletions
|
@ -53,18 +53,18 @@ fn ps(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, She
|
||||||
pin_utils::pin_mut!(processes);
|
pin_utils::pin_mut!(processes);
|
||||||
|
|
||||||
while let Some(res) = processes.next().await {
|
while let Some(res) = processes.next().await {
|
||||||
let (process, usage) = res.unwrap();
|
if let Ok((process, usage)) = res {
|
||||||
|
let mut dict = TaggedDictBuilder::new(Tag::unknown_origin(span));
|
||||||
let mut dict = TaggedDictBuilder::new(Tag::unknown_origin(span));
|
dict.insert("pid", Value::int(process.pid()));
|
||||||
dict.insert("pid", Value::int(process.pid()));
|
if let Ok(name) = process.name().await {
|
||||||
if let Ok(name) = process.name().await {
|
dict.insert("name", Value::string(name));
|
||||||
dict.insert("name", Value::string(name));
|
}
|
||||||
|
if let Ok(status) = process.status().await {
|
||||||
|
dict.insert("status", Value::string(format!("{:?}", status)));
|
||||||
|
}
|
||||||
|
dict.insert("cpu", Value::float(usage.get::<ratio::percent>() as f64));
|
||||||
|
yield ReturnSuccess::value(dict.into_tagged_value());
|
||||||
}
|
}
|
||||||
if let Ok(status) = process.status().await {
|
|
||||||
dict.insert("status", Value::string(format!("{:?}", status)));
|
|
||||||
}
|
|
||||||
dict.insert("cpu", Value::float(usage.get::<ratio::percent>() as f64));
|
|
||||||
yield ReturnSuccess::value(dict.into_tagged_value());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue