#!/bin/bash
export LIBDIR="/usr/lib/gentoo-perl-helpers"
export LIBEXECDIR="/usr/libexec/gentoo-perl-helpers"

if [[ ${LIBDIR:0:2} == "@@" ]]; then
  export LIBDIR="$PWD/lib"
  export LIBEXECDIR="$PWD/libexec"
fi

export PATH="${LIBEXECDIR}:$PATH"

source "${LIBDIR}/core-functions.sh"

my_command="help"

if [[ $# == 0 ]]; then
  eerror "No command specified";
  dorun "help"
  exit $?
else
  if [[ ${1:1:0}  == '-' ]]; then
    eerror "Unknown command $1"
    dorun "help"
    exit $?
  else
    my_command="$1"
    shift
    dorun $my_command "$@"
    exit $?
  fi
fi

#fullcommand="${LIBEXECDIR%/}/${my_command}"
#
#if [[ ! -e "${fullcommand}" ]]; then
#  die "No such command ${my_command}, ${fullcommand} does not exist";
#fi
#if [[ ! -x "${fullcommand}" ]]; then
#  die "${fullcommand} is not executable";
#fi

#export FULL_COMMAND="${BINSCRIPT}"
#dorun "${fullcommand}" "$@"
