specta-rs / tauri-specta

Completely typesafe Tauri commands
MIT License
394 stars 41 forks source link

Allow change generated code naming convention #105

Open sbant opened 5 months ago

sbant commented 5 months ago

As Rust code use snake_case, but in tauri-specta's code use "to_lower_camel_case" to force convert all name to camelCase.

Is there any way to keep the original naming convention or change as user like in the generated bindings.ts

Tauri official can has "rename_all" to change the function name (https://tauri.app/v1/guides/features/command/)

#[tauri::command(rename_all = "snake_case")]
fn my_custom_command(invoke_message: String) {
  println!("I was invoked from JS, with this message: {}", invoke_message);
}

I've test tauri-specta with "rename_all" use both "snake_case" and "camelCase", but they don't change the code generated.

taurpc can use "alias" to change name as user like. (https://crates.io/crates/taurpc)

#[taurpc::procedures]
trait Api {
    // #[taurpc(skip)]
    #[taurpc(alias = "_hello_world_")]
    async fn hello_world();
}
oscartbeaumont commented 5 months ago

Right now we don't have a way to do. Support for it is required in Specta and is tracked by issue oscartbeaumont/specta#213.