Initial Renamr scaffold: Tauri (Rust core + React/TS UI), naming-expression engine ported+tested
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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()
|
||||
.invoke_handler(tauri::generate_handler![render_expression])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running Renamr");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Prevents an additional console window on Windows in release builds.
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
renamr_lib::run();
|
||||
}
|
||||
Reference in New Issue
Block a user