Files
aurora-curator/src-tauri/src/lib.rs
T

31 lines
1.1 KiB
Rust
Raw Normal View History

mod files;
use renamr_core::format::ExpressionFormat;
use renamr_core::string_bindings;
use std::collections::HashMap;
/// Renders a naming-scheme expression against a set of binding values.
/// This is the Tauri-facing entry point into the core format engine, used by the
/// rename-preview panel in the UI so users see live results as they edit a pattern.
#[tauri::command]
fn render_expression(expression: String, bindings: HashMap<String, String>) -> Result<String, String> {
let compiled = ExpressionFormat::compile(&expression).map_err(|e| e.to_string())?;
compiled
.format(&string_bindings(bindings))
.map_err(|e| e.to_string())
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_dialog::init())
.invoke_handler(tauri::generate_handler![
render_expression,
files::pick_files,
files::pick_folder,
files::expand_dropped_paths,
])
.run(tauri::generate_context!())
.expect("error while running Renamr");
}