Code Monkey home page Code Monkey logo

forma's Introduction

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:

[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.

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

forma's People

Contributors

maxcountryman avatar dependabot-preview[bot] avatar dandandan avatar bluemoon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.