Skip to content

Commit

Permalink
feat: add status() method to Command (#1473)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi authored Aug 12, 2024
1 parent a39409e commit 71d6b0d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions yazi-plugin/src/process/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use mlua::{AnyUserData, ExternalError, IntoLuaMulti, Lua, Table, UserData, Value
use tokio::process::{ChildStderr, ChildStdin, ChildStdout};

use super::{output::Output, Child};
use crate::process::Status;

pub struct Command {
inner: tokio::process::Command,
Expand Down Expand Up @@ -112,5 +113,11 @@ impl UserData for Command {
Err(e) => (Value::Nil, e.raw_os_error()).into_lua_multi(lua),
}
});
methods.add_async_method_mut("status", |lua, me, ()| async move {
match me.inner.status().await {
Ok(status) => (Status::new(status), Value::Nil).into_lua_multi(lua),
Err(e) => (Value::Nil, e.raw_os_error()).into_lua_multi(lua),
}
});
}
}

0 comments on commit 71d6b0d

Please sign in to comment.