#!/bin/sh
set -e

CLIP="$(xclip -quiet -o | col -b | head -n 1 | sed 's/-[0-9].*//g' | tr -d ':;[]')"

if [ -z "$CLIP" ]
then
    echo "pview: no data"
    exit 1
fi

if [ ! -d "/usr/ports/$CLIP" ]
then
    echo "pview: invalid data \"$CLIP\""
    exit 1
fi

cd "/usr/ports/$CLIP"
P=$(make show=PKGNAME)
R=$(make show=REVISION)
echo "PKG: $P"
echo "REV: $R"
