feat: add ya.shell_join() API

This commit is contained in:
sxyazi 2024-02-05 09:00:48 +08:00
parent 715fbf5b65
commit 9e113a9337
No known key found for this signature in database

View file

@ -35,6 +35,19 @@ impl Utils {
lua.create_function(|_, mime: mlua::String| Ok(mime_valid(mime.as_bytes())))?,
)?;
ya.set(
"shell_join",
lua.create_function(|_, table: Table| {
let mut s = String::new();
for v in table.sequence_values::<mlua::String>() {
s.push_str(shell_words::quote(v?.to_str()?).as_ref());
s.push(' ');
}
s.pop();
Ok(s)
})?,
)?;
Ok(())
}
}