← Commit history

rust: accept bare verb names (ab strips the prefix before forwarding)

John Lauer ·c10830a706 ·28d ago ·parent 3ceff1d
1 file changed +5−1
rust/crates/kicad-bridge/src/verbs.rs+5−1
@@ -12,7 +12,11 @@ use kicad_core::detect; use kicad_platform::native; use crate::Caller; -pub fn dispatch(state: &mut State, command: &str, args: &Value, _caller: &Caller) -> Value {+pub fn dispatch(state: &mut State, command_in: &str, args: &Value, _caller: &Caller) -> Value {+    // ab forwards the bare name (it strips the `kicad_` prefix it routed on); the CLI and+    // hand callers send the full one. Accept both, like the Python bridge.+    let full: String = if command_in.starts_with("kicad_") { command_in.to_string() } else { format!("kicad_{command_in}") };+    let command = full.as_str();     let Some(verb) = catalog::find(command) else {         let names: Vec<&str> = catalog::all().iter().map(|v| v.name).collect();         return fail("unknown_verb", format!("Unknown command: {command}"), format!("Valid commands: {}", names.join(", ")));