Sleek is a CLI tool for formatting SQL files. It helps you maintain a consistent style across your SQL code, enhancing readability and productivity.
The heavy lifting is done by the sql-formatter crate.
To install Sleek, you'll need to have Rust installed on your system. Once Rust is installed, follow these simple steps:
bash
cargo install sleek
bash
sleek [FLAGS] [OPTIONS] <file_paths>...
<file_paths>...
: File path(s) to format, supports glob patterns.-c
, --check
: Check if the code is already formatted. If not, it will exit
with an error message.-h
, --help
: Prints help information.-V
, --version
: Prints version information.-i
, --indent_spaces <indent_spaces>
: Set the number of spaces to use for
indentation (default: 4).-U
, --uppercase <uppercase>
: Change reserved keywords to ALL CAPS
(default: true).-l
, --lines_between_queries <lines_between_queries>
: Set the number of
line breaks after a query (default: 1).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"
This project is available under the MIT License.