mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
feat: new cf.args to access startup arguments (#2392)
This commit is contained in:
parent
6ca27597f9
commit
f11f77d7b9
1 changed files with 13 additions and 1 deletions
|
|
@ -1,7 +1,8 @@
|
|||
use mlua::{IntoLua, Lua, LuaSerdeExt, SerializeOptions, Value};
|
||||
use yazi_boot::ARGS;
|
||||
use yazi_config::{MANAGER, PREVIEW, THEME};
|
||||
|
||||
use crate::Composer;
|
||||
use crate::{Composer, url::Url};
|
||||
|
||||
pub const OPTS: SerializeOptions =
|
||||
SerializeOptions::new().serialize_none_to_null(false).serialize_unit_to_null(false);
|
||||
|
|
@ -14,6 +15,7 @@ impl<'a> Config<'a> {
|
|||
pub fn compose(lua: &Lua) -> mlua::Result<Value> {
|
||||
Composer::make(lua, 5, |lua, key| {
|
||||
match key {
|
||||
b"args" => Self::args(lua)?,
|
||||
b"manager" => Self::manager(lua)?,
|
||||
b"plugin" => super::Plugin::compose(lua)?,
|
||||
b"preview" => Self::preview(lua)?,
|
||||
|
|
@ -23,6 +25,16 @@ impl<'a> Config<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
fn args(lua: &Lua) -> mlua::Result<Value> {
|
||||
Composer::make(lua, 5, |lua, key| {
|
||||
match key {
|
||||
b"chooser_file" => ARGS.chooser_file.as_ref().map(Url::from).into_lua(lua)?,
|
||||
_ => return Ok(Value::Nil),
|
||||
}
|
||||
.into_lua(lua)
|
||||
})
|
||||
}
|
||||
|
||||
fn manager(lua: &Lua) -> mlua::Result<Value> {
|
||||
Composer::make(lua, 5, |lua, key| {
|
||||
match key {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue