mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Run rustfmt +nightly **/*.rs and rebase
This commit is contained in:
parent
bb887f9230
commit
87d63dc273
1 changed files with 75 additions and 82 deletions
|
|
@ -1,7 +1,8 @@
|
|||
use std::process::Stdio;
|
||||
use std::ffi::OsString;
|
||||
use std::{ffi::OsString, process::Stdio};
|
||||
|
||||
use mlua::{AnyUserData, ExternalError, IntoLuaMulti, Lua, Table, UserData, Value};
|
||||
use tokio::process::{ChildStderr, ChildStdin, ChildStdout};
|
||||
|
||||
use super::{Child, output::Output};
|
||||
use crate::process::Status;
|
||||
|
||||
|
|
@ -17,18 +18,12 @@ impl Command {
|
|||
pub fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
let new = lua.create_function(|_, (_, program): (Table, String)| {
|
||||
let mut inner = tokio::process::Command::new(program);
|
||||
inner.kill_on_drop(true)
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null());
|
||||
inner.kill_on_drop(true).stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null());
|
||||
Ok(Self { inner })
|
||||
})?;
|
||||
|
||||
let command = lua.create_table_from([
|
||||
("NULL", NULL),
|
||||
("PIPED", PIPED),
|
||||
("INHERIT", INHERIT),
|
||||
])?;
|
||||
let command =
|
||||
lua.create_table_from([("NULL", NULL), ("PIPED", PIPED), ("INHERIT", INHERIT)])?;
|
||||
|
||||
command.set_metatable(Some(lua.create_table_from([("__call", new)])?));
|
||||
lua.globals().raw_set("Command", command)
|
||||
|
|
@ -70,10 +65,8 @@ impl UserData for Command {
|
|||
});
|
||||
|
||||
methods.add_function_mut("args", |_, (ud, args): (AnyUserData, Vec<mlua::String>)| {
|
||||
let args: Vec<OsString> = args
|
||||
.iter()
|
||||
.map(|arg| OsString::from(arg.to_str().unwrap()))
|
||||
.collect();
|
||||
let args: Vec<OsString> =
|
||||
args.iter().map(|arg| OsString::from(arg.to_str().unwrap())).collect();
|
||||
ud.borrow_mut::<Self>()?.inner.args(&args);
|
||||
Ok(ud)
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue