#!/bin/sh
# $Id: y2tool 14862 2004-02-27 11:46:36Z mvidner $
#
# y2tool - Start a YaST2 tool from the YaST2 tool path
#
# Author: Stefan Hundhammer <sh@suse.de>
# (c) SuSE GmbH 2001
#

self=`basename $0`

if [ "$1" == "--prefix" -o "$1" == "-p" ]; then
    shift
    prefix="$1"
    shift
fi

# run the tools that are in the same prefix as we are
if [ -z "$prefix" ]; then
    if [ `dirname $0` == "." ]; then
	y2toolpath=.
    else
	prefix=${0%/bin/$self}
	y2toolpath=${prefix}/share/YaST2/data/devtools/bin
    fi
fi

cmd=$1
shift

if [ "$cmd" == "--help" ]; then
    cd $y2toolpath
    ls
    exit 0
fi

if [ -z $cmd ]; then
    echo ""							>&2
    echo "Usage: ${self} [--prefix <prefix>] [--help] <command> [<arg> ...]">&2
    echo ""							>&2
    echo "Starts a YaST2 tool from '$y2toolpath'."		>&2
    echo ""							>&2
    exit 1
fi


if [ -x $y2toolpath/$cmd ]; then
    $y2toolpath/$cmd "$@"
else
    echo "${self}: Can't find \"$cmd\" in $y2toolpath"	>&2
    exit 1
fi
