2014-11-07 14:49:16 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2014-11-09 14:57:00 +01:00
|
|
|
ME=`basename $0`
|
2014-11-09 22:06:20 +01:00
|
|
|
COMMANDDIR=`dirname $0`/lib
|
2014-11-09 14:57:00 +01:00
|
|
|
test -d ${COMMANDDIR} || COMMANDDIR=/usr/lib/`basename $0`
|
|
|
|
|
|
|
|
help() {
|
|
|
|
msg="$1"
|
|
|
|
test -n "$msg" && echo $msg
|
2014-11-26 13:38:45 +01:00
|
|
|
echo "syntaxe: $ME commande ..."
|
2014-11-09 14:57:00 +01:00
|
|
|
echo ""
|
2014-11-26 13:38:45 +01:00
|
|
|
echo "commandes disponibles:"
|
|
|
|
echo " help cette aide"
|
2014-11-09 14:57:00 +01:00
|
|
|
for fcom in $COMMANDDIR/*.help
|
|
|
|
do
|
|
|
|
com=`basename $fcom .help`
|
2014-11-10 00:00:41 +01:00
|
|
|
descr=`head -1 $fcom`
|
2014-11-09 14:57:00 +01:00
|
|
|
echo " "$com" "$descr
|
|
|
|
done
|
|
|
|
test -n "$msg" && exit 1
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
helpcmd() {
|
|
|
|
command=$1
|
|
|
|
xcommand=$COMMANDDIR/$command
|
2014-11-26 13:38:45 +01:00
|
|
|
test -x $xcommand || help "ERR: commande inconnue ($command)"
|
2014-11-09 14:57:00 +01:00
|
|
|
echo "$ME $command"
|
|
|
|
cat $xcommand.help
|
|
|
|
}
|
|
|
|
|
|
|
|
command=$1
|
2014-11-26 13:38:45 +01:00
|
|
|
test -z $command && help "ERR: commande manquante"
|
2014-11-09 14:57:00 +01:00
|
|
|
shift
|
|
|
|
|
|
|
|
case $command in
|
|
|
|
help)
|
|
|
|
test -z "$1" && help
|
|
|
|
helpcmd $1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
xcommand=$COMMANDDIR/$command
|
2014-11-26 13:38:45 +01:00
|
|
|
test -x $xcommand || help "ERR: commande inconnue ($command)"
|
2014-11-10 00:06:10 +01:00
|
|
|
$xcommand "$@"
|
2014-11-09 14:57:00 +01:00
|
|
|
;;
|
|
|
|
esac
|