Skip to content

Commit 71d6b0d

Browse files
authored
feat: add status() method to Command (#1473)
1 parent a39409e commit 71d6b0d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

yazi-plugin/src/process/command.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use mlua::{AnyUserData, ExternalError, IntoLuaMulti, Lua, Table, UserData, Value
44
use tokio::process::{ChildStderr, ChildStdin, ChildStdout};
55

66
use super::{output::Output, Child};
7+
use crate::process::Status;
78

89
pub struct Command {
910
inner: tokio::process::Command,
@@ -112,5 +113,11 @@ impl UserData for Command {
112113
Err(e) => (Value::Nil, e.raw_os_error()).into_lua_multi(lua),
113114
}
114115
});
116+
methods.add_async_method_mut("status", |lua, me, ()| async move {
117+
match me.inner.status().await {
118+
Ok(status) => (Status::new(status), Value::Nil).into_lua_multi(lua),
119+
Err(e) => (Value::Nil, e.raw_os_error()).into_lua_multi(lua),
120+
}
121+
});
115122
}
116123
}

0 commit comments

Comments
 (0)