Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat]: Reduce boilerplate for command definitions in Tauri v2 #10075

Open
Norbiros opened this issue Jun 17, 2024 · 0 comments
Open

[feat]: Reduce boilerplate for command definitions in Tauri v2 #10075

Norbiros opened this issue Jun 17, 2024 · 0 comments

Comments

@Norbiros
Copy link

Describe the problem

I am currently updating a large project to Tauri v2, which involves around 100 commands. While doing so, I have encountered a significant amount of boilerplate code that I need to maintain across multiple files. Specifically, for each command, I need to:

  • Define the command in the plugin's init function:
.invoke_handler(tauri::generate_handler![auth_get_default_user, auth_set_default_user])
  • Include the command in build.rs:
.plugin(
    "auth",
        tauri_build::InlinedPlugin::new().commands(&["auth_get_default_user", "auth_set_default_user"]),
)
  • Allow for usage of my commands in capatabilities.json:
"auth:allow-auth-get-default-user",
"auth:allow-auth-set-default-user"

This process is not only repetitive but also makes it challenging to maintain and scale the project.

Describe the solution you'd like

Anything that reduces boilerplate, for example:

  • New macro that works like tauri::generate_handler!, but also generates all permissions
  • Allowing for all plugin's commands (for example plugin:allow-all or plugin:allow-*)

Alternatives considered

No response

Additional context

I initially discussed this problem on Discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants