#sql #sql-format #format #cli

app slikr

Slikr is a CLI tool for formatting SQL files with configurable options

1 unstable release

Uses new Rust 2024

0.6.0 Apr 3, 2026

#436 in Development tools

MIT license

23KB
413 lines

Slikr

A fork of Sleek with added configuration file support. Slikr automatically looks for a config file (.slikr.json), and falls back to default settings if no config file or options/flags are provided.


Features

  • Format SQL files using customisable indentation and character case options
  • Supports glob patterns, allowing you to format multiple files and patterns
  • Check whether your SQL files are already formatted without altering them with the --check flag
  • Uppercase keywords by default (disable with --uppercase false)
  • Automatically adds trailing newlines to formatted output (disable with --trailing-newline false)
  • New: Read from a specific JSON config file with -C, --config <PATH>
  • Searches for default config file .slikr.json in current working directory and home directory if not explicitly provided

Installation

Download Compiled Binaries

You can download the compiled binaries for Slikr from the Releases page. Choose the binary that corresponds to your operating system and architecture, and place it in a directory included in your system's PATH.

Install with Cargo

To install Slikr using Cargo, you need Rust installed on your system. Once Rust is installed:

cargo install slikr

Usage

slikr [OPTIONS] [FILE]...

Arguments

  • [FILE]...: File path(s) to format, supports glob patterns. If no file paths are provided, reads from stdin or falls back to defaults.

Options

Flag Description
-C, --config <PATH> Path to a JSON config file
-c, --check Check if the code is already formatted without modifying files
-i, --indent-spaces <NUM> Number of spaces to use for indentation (default: 4)
-U, --uppercase <BOOL> Convert reserved keywords to UPPERCASE (default: true)
-l, --lines-between-queries <NUM> Number of line breaks to insert after each query (default: 2)
-n, --trailing-newline <BOOL> Ensure files end with a trailing newline (default: true)
-h, --help Print help
-V, --version Print version

Examples

Note: Boolean flags require explicit values. Both formats work:

# Space format
slikr --uppercase true

# Equals format
slikr --uppercase=true

Format a query from stdin:

echo "select * from users" | slikr --uppercase true

Check if a query is formatted correctly from stdin:

echo "select * from users" | slikr --check

Format a single file using default options if no config file is found:

slikr my_query.sql

Format multiple files using a glob pattern:

slikr "queries/*.sql"

Format files with custom options:

slikr --indent-spaces 2 --uppercase false "queries/*.sql"

Format files with a specific config file:

slikr --config /path/to/myconfig.json "queries/*.sql"
# or
slikr -C /path/to/myconfig.json "queries/*.sql"

Check if files are already formatted:

slikr --check "queries/*.sql"

Format files without trailing newlines:

slikr --trailing-newline false "queries/*.sql"

Original Project

This is a fork of Sleek — for the original CLI, VS Code extension, and full documentation, see their repository.

Dependencies

~2.8–5.5MB
~112K SLoC