bit-twiddler 0.2.0

Cross-platform developer toolbox: bit manipulation, hashing, YAML/JSON/SQL, QR, Markdown, cron, and 40+ more tools — Tauri v2, no Node.js
use sqlformat::{format, Dialect, FormatOptions, Indent, QueryParams};

#[tauri::command]
pub fn format_sql(sql: String, language: String) -> Result<String, String> {
    // sqlformat only distinguishes Generic / PostgreSql / SQLServer; other
    // dialect choices in the UI (MySQL, MariaDB, SQLite, PL/SQL) format as
    // Generic since the crate has no dedicated support for them.
    let dialect = match language.as_str() {
        "postgresql" => Dialect::PostgreSql,
        "tsql" => Dialect::SQLServer,
        _ => Dialect::Generic,
    };

    let options = FormatOptions {
        indent: Indent::Spaces(2),
        uppercase: Some(true),
        lines_between_queries: 2,
        dialect,
        ..FormatOptions::default()
    };
    Ok(format(&sql, &QueryParams::None, &options))
}