mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
feat: add status() method to Command (#1473)
This commit is contained in:
parent
a39409e699
commit
71d6b0d9f2
1 changed files with 7 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
@ -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),
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue