mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-25 18:56:50 -06:00
fix(cli): reject --pdf-options that is not a JSON object instead of panicking (#731)
This commit is contained in:
@@ -261,7 +261,11 @@ fn run(args: &[String]) -> Result<(), String> {
|
||||
"--page" => page = val()?.parse().map_err(|_| "bad --page")?,
|
||||
"--scale" => scale = val()?.parse().map_err(|_| "bad --scale")?,
|
||||
"--pdf-options" => {
|
||||
pdf_opts = serde_json::from_str(&val()?).map_err(|e| format!("--pdf-options: {e}"))?;
|
||||
pdf_opts = match serde_json::from_str(&val()?).map_err(|e| format!("--pdf-options: {e}"))? {
|
||||
Value::Null => json!({}),
|
||||
o @ Value::Object(_) => o,
|
||||
_ => return Err("--pdf-options: expected a JSON object".to_string()),
|
||||
};
|
||||
}
|
||||
"--export" => {
|
||||
let out = val()?;
|
||||
|
||||
Reference in New Issue
Block a user