Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of --option flag in Rust CLI #2137

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<String>>,

/// Include the contents of a SIL, XML, or other resource file before the input document content.
Expand Down
10 changes: 9 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")?;
Expand Down
Loading