#!/bin/sh

if [ "$SUDO_UID" = "" ]; then
	sudo $0 "$@"
	exit $?
fi

LIBEXECDIR="/usr/libexec/vbuilder"

function usage()
{
	cat <<EOF
vbuilder version 2.0.0

usage: $0 <command> <args>

commands:
  create          create an environment
  update          reset and update the environment
  reset           reset the environment
  add             install package(s) into the environment
  build           build package(s)
  login           log into the environment
  help <command>  show details of <command>

EOF
}


COMMAND=$1
shift

if [ "$COMMAND" != "" -a -x "$LIBEXECDIR/vbuilder-$COMMAND" ]; then
	$LIBEXECDIR/vbuilder-$COMMAND "$@"
else
	if [ "$COMMAND" = "help" -a -x "$LIBEXECDIR/vbuilder-$1" ]; then
		$LIBEXECDIR/vbuilder-$1 --help
	else
		usage
	fi
fi

