sqlglot-rust 0.9.27

A SQL parser, optimizer, and transpiler library inspired by Python's sqlglot
Documentation
# Homebrew formula for sqlglot CLI.
#
# Install:  brew install protegrity/tap/sqlglot
# Upgrade:  brew upgrade sqlglot
#
# This formula downloads pre-built binaries from GitHub Releases.
# To use the C/C++ FFI libraries, download the full tarball from the release page.

class Sqlglot < Formula
  desc "SQL parser, optimizer, and transpiler CLI — 30 dialects"
  homepage "https://github.com/protegrity/sql-glot-rust"
  version "@@VERSION@@"
  license "MIT"

  on_macos do
    if Hardware::CPU.arm?
      url "https://github.com/protegrity/sql-glot-rust/releases/download/v@@VERSION@@/sqlglot-@@VERSION@@-macos-arm64.tar.gz"
      sha256 "@@SHA256_ARM64@@"
    else
      url "https://github.com/protegrity/sql-glot-rust/releases/download/v@@VERSION@@/sqlglot-@@VERSION@@-macos-amd64.tar.gz"
      sha256 "@@SHA256_AMD64@@"
    end
  end

  on_linux do
    if Hardware::CPU.arm?
      url "https://github.com/protegrity/sql-glot-rust/releases/download/v@@VERSION@@/sqlglot-@@VERSION@@-linux-arm64.tar.gz"
      sha256 "@@SHA256_LINUX_ARM64@@"
    else
      url "https://github.com/protegrity/sql-glot-rust/releases/download/v@@VERSION@@/sqlglot-@@VERSION@@-linux-amd64.tar.gz"
      sha256 "@@SHA256_LINUX_AMD64@@"
    end
  end

  def install
    bin.install "bin/sqlglot"
    lib.install Dir["lib/*"]
    include.install "include/sqlglot.h"
    doc.install "README.md", "LICENSE"
  end

  test do
    assert_match version.to_s, shell_output("#{bin}/sqlglot --version")
    result = pipe_output("#{bin}/sqlglot transpile --read mysql --write postgres", "SELECT NOW()")
    assert_match "NOW()", result
  end
end