From 6128b33bbeb8f44d17bbc94c598c7b8ff68f8e10 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 16 Oct 2024 13:46:54 +0300 Subject: [PATCH 1/2] chore(cli): Add alias to legacy --options flag plural spelling --- src/cli.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index f4baa1590..fb766e0d3 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -91,9 +91,9 @@ pub struct Cli { /// Set or override document class options. /// /// Can be used to change default options or override the ones specified in a document. - /// For example setting `--options papersize=letter` would override both the default `papersize` of A4 and any specific one set in the document’s options. + /// For example setting `--option papersize=letter` would override both the default `papersize` of A4 and any specific one set in the document’s options. /// May be specified more than once. - #[clap(short = 'O', long)] + #[clap(short = 'O', long, alias = "options")] pub option: Option>, /// Include the contents of a SIL, XML, or other resource file before the input document content. From a77170eccda81befccff7e3a5d8a14eb686f6df3 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 16 Oct 2024 14:01:07 +0300 Subject: [PATCH 2/2] fix(cli): Fix handling of --option flag in Rust CLI --- src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index dc7e48fb4..77af6a24e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -133,7 +133,15 @@ pub fn run( has_input_filename = true; } if let Some(options) = options { - sile_input.set("options", options)?; + // TODO: when mlua v0.10 merges, adapt this like the uses parsing to avoid chunking + for option in options.iter() { + let option = lua.create_string(option)?; + lua.load(chunk! { + local parameter = SILE.parserBits.parameters:match($option); + SILE.input.options = pl.tablex.merge(SILE.input.options, parameter, true) + }) + .eval::<()>()?; + } } if let Some(modules) = uses { // let parser_bits: LuaTable = sile.get("parserBits")?;