Add kclVersion as a field of the setting attribute (#6689)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -262,13 +262,14 @@ pub fn kcl_settings(program_json: &str) -> Result<JsValue, String> {
|
||||
|
||||
/// Takes a kcl string and Meta settings and changes the meta settings in the kcl string.
|
||||
#[wasm_bindgen]
|
||||
pub fn change_kcl_settings(code: &str, settings_str: &str) -> Result<String, String> {
|
||||
pub fn change_default_units(code: &str, len_str: &str, angle_str: &str) -> Result<String, String> {
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
let settings: kcl_lib::MetaSettings = serde_json::from_str(settings_str).map_err(|e| e.to_string())?;
|
||||
let len: Option<kcl_lib::UnitLen> = serde_json::from_str(len_str).map_err(|e| e.to_string())?;
|
||||
let angle: Option<kcl_lib::UnitAngle> = serde_json::from_str(angle_str).map_err(|e| e.to_string())?;
|
||||
let program = Program::parse_no_errs(code).map_err(|e| e.to_string())?;
|
||||
|
||||
let new_program = program.change_meta_settings(settings).map_err(|e| e.to_string())?;
|
||||
let new_program = program.change_default_units(len, angle).map_err(|e| e.to_string())?;
|
||||
|
||||
let formatted = new_program.recast();
|
||||
|
||||
|
Reference in New Issue
Block a user