# Description: xdg-utils replacement written in rust
# URL: https://github.com/Anomalocaridid/handlr-regex
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: rust xdg-utils

name=handlr
version=0.8.5
release=1
source=(https://github.com/Anomalocaridid/handlr-regex/archive/v$version/$name-$version.tar.gz
  xdg-open.sh)

build() {
  prt-get isinst sccache && export RUSTC_WRAPPER=/usr/bin/sccache
  [[ ! -e $PKGMK_SOURCE_DIR/rust ]] && mkdir $PKGMK_SOURCE_DIR/rust

  cargo build --release --manifest-path $name-regex-$version/Cargo.toml

  prt-get isinst bash-completion && install -Dm644 $SRC/$name-regex-$version/assets/completions/handlr \
    $PKG/usr/share/bash-completion/completions/handlr
  prt-get isinst zsh && install -Dm644 $SRC/$name-regex-$version/assets/completions/_handlr \
    $PKG/usr/share/zsh/site-functions/_handlr

  install -Dt $PKG/usr/bin $name-regex-$version/target/release/$name
  install -Dm755 $SRC/xdg-open.sh $PKG/usr/local/bin/xdg-open
}
