# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           golang 1.0

go.setup            github.com/xo/usql 0.21.4 v
go.toolchain_min    1.26.1
go.offline_build    no
revision            1

description         Universal command-line interface for SQL databases

long_description    \
    ${name} is a universal command-line interface for PostgreSQL, MySQL, \
    Oracle Database, SQLite3, Microsoft SQL Server, and many other databases \
    including NoSQL and non-relational databases. ${name} provides a simple \
    way to work with SQL and NoSQL databases via a command-line inspired by \
    PostgreSQL's psql. ${name} supports most of the core psql features, such \
    as variables, backticks, and commands and has additional features that \
    psql does not, such as syntax highlighting, context-based completion, \
    and multiple database support.

categories          databases
installs_libs       no
license             MIT
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

checksums           rmd160  3986f650518fe6d2392f5d3c8120c5bd2041604c \
                    sha256  6dfe613eff669606ba52f8c4a046d70677c47b2af61e87dc471ae2c44e50cca7 \
                    size    338480

depends_build-append \
                    port:realpath

# 0.21.4 depends on cockroachdb/swiss, which does not build with Go 1.27.
# build.sh calls go from PATH, so pin the series there rather than via go.bin.
depends_build-append \
                    port:go-1.26
build.env-append    PATH=${prefix}/lib/go-1.26/bin:$env(PATH)

build.cmd           ./build.sh
build.args          -v ${github.tag_prefix}${version}

patch {
    reinplace -E {/^[[:space:]]*TAR=gtar/   d}  ${worksrcpath}/build.sh
    reinplace -E {/^[[:space:]]*sha256sum/  d}  ${worksrcpath}/build.sh
}

destroot {
    xinstall -m 0755 \
        [glob ${worksrcpath}/build/${goos}/*/*/${name}] \
        ${destroot}${prefix}/bin/
}
