# -*- 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           github 1.0

github.setup        xwmx nb 7.16.1
github.tarball_from archive
revision            0

homepage            https://xwmx.github.io/nb/

description         \
    ${name} is a command line and local web note‑taking, bookmarking, \
    archiving, and knowledge base application.

long_description    \
    {*}${description} ${name} creates notes in text-based formats like \
    Markdown, Org, LaTeX, and AsciiDoc, can work with files in any format, \
    can import and export notes to many document formats, and can create \
    private, password-protected encrypted notes and bookmarks. With ${name}, \
    you can write notes using Vim, Emacs, VS Code, Sublime Text, and any \
    other text editor you like, as well as terminal and GUI web browsers. \
    ${name} works in any standard Linux / Unix environment, including macOS \
    and Windows via WSL. Optional dependencies can be installed to enhance \
    functionality, but ${name} works great without them.

categories          office
platforms           any
license             AGPL-3
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer
supported_archs     noarch

checksums           rmd160  c955b15df4b2c0e78f5d83f9a3ca9098b00d5804 \
                    sha256  d173f20041ecf35f74ce1e559c78eb3c4ecf4bd790b44bacccc1769503164dd6 \
                    size    753954

depends_lib-append  port:bash

depends_run-append  bin:git:git

use_configure       no

patch {
    foreach script {nb bin/bookmark} {
        reinplace "s|#!/usr/bin/env bash|#!${prefix}/bin/bash|" \
            ${worksrcpath}/${script}
    }
}

build {}

destroot {
    xinstall -m 0755 ${worksrcpath}/${name}         ${destroot}${prefix}/bin/
    xinstall -m 0755 ${worksrcpath}/bin/bookmark    ${destroot}${prefix}/bin/
    xinstall -m 0755 ${worksrcpath}/bin/notes       ${destroot}${prefix}/bin/

    xinstall -d ${destroot}${prefix}/share/bash-completion/completions
    copy ${worksrcpath}/etc/${name}-completion.bash \
        ${destroot}${prefix}/share/bash-completion/completions/${name}

    xinstall -d ${destroot}${prefix}/share/fish/vendor_completions.d
    copy ${worksrcpath}/etc/${name}-completion.fish \
        ${destroot}${prefix}/share/fish/vendor_completions.d/${name}.fish

    xinstall -d ${destroot}${prefix}/share/zsh/site-functions
    copy ${worksrcpath}/etc/${name}-completion.zsh \
        ${destroot}${prefix}/share/zsh/site-functions/_${name}
}
