Sleek: SQL Formatter ✨

Crates.io GitHub Actions

Sleek is a CLI tool for formatting SQL files and strings. It helps you maintain a consistent style across your SQL code, enhancing readability and productivity.

The heavy lifting is done by the sqlformat crate.

Before and After

Here's an example of a SQL query before and after being formatted by Sleek:

Before

sql select id, name, email from users where id in (select user_id from orders where total > 100) and status = 'active'

After

sql SELECT id, name, email FROM users WHERE id IN ( SELECT user_id FROM orders WHERE total > 100 ) AND STATUS = 'active'

Features

Installation

To install Sleek, you'll need to have Rust installed on your system. Once Rust is installed, you can install Sleek with Cargo:

bash cargo install sleek

Usage

bash sleek [FLAGS] [OPTIONS] <file_paths>...

Arguments

Flags

Options

Examples

To check if a query is formatted correctly:

```bash

echo "select * from users" | sleek --check Input is not formatted correctly. Run without --check to format the input. ```

To format a single file with the default options:

bash sleek my_query.sql

To format multiple files using a glob pattern:

bash sleek "queries/*.sql"

To format files with custom options:

bash sleek --indent_spaces 2 --uppercase false "queries/*.sql"

To check if files are already formatted:

bash sleek --check "queries/*.sql"

License

This project is available under the MIT License.