Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxcountryman/forma
🐚 An opinionated SQL formatter.
https://github.com/maxcountryman/forma
format-sql formatter pretty-printer sql sql-formatter
Last synced: 14 days ago
JSON representation
🐚 An opinionated SQL formatter.
- Host: GitHub
- URL: https://github.com/maxcountryman/forma
- Owner: maxcountryman
- Created: 2020-05-01T04:03:35.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-20T22:32:02.000Z (almost 2 years ago)
- Last Synced: 2024-10-27T01:37:26.673Z (19 days ago)
- Topics: format-sql, formatter, pretty-printer, sql, sql-formatter
- Language: Rust
- Homepage:
- Size: 1.78 MB
- Stars: 27
- Watchers: 4
- Forks: 3
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
forma 🐚
An opinionated SQL formatter.
## 📦 Install
The binary may be installed via `cargo`:
```
$ cargo install forma
```Further the companion library `formation` may be required as a dependency:
```toml
[dependencies]
formation = "0.3.0"
```## 🤸 Usage
> ⚠️ `forma` should be considered alpha quality, with several known, and many
more unknown deficiencies. **Use at your own risk!**Give `forma` some SQL via a file path or stdin and you'll get back formatted
SQL.```
$ echo "SELECT * FROM users" | forma
select * from users;
```To format a SQL file, simply give `forma` the file path.
```
$ forma path/to/some/sql/example.sql
```And if you'd prefer to not actually format the SQL but know if formatting
would happen then use the `--check` flag.The binary is a thin wrapper around the `formation` library, which can be used
in your own applications to format SQL.```rust
use formation::format;
let sql = "SELECT * FROM users;";
assert_eq!(
format(sql, false, 100).unwrap(),
vec!["select * from users;\n".to_owned()]
);
```## 🚧 TODOs
- [ ] Comprehensive `Statement` variant support (currently only `Query`)
- [ ] Support for comments (these will be eaten by the formatter!)
- [ ] Parameterized dialects