summaryrefslogtreecommitdiff
path: root/src/rvs.sh
blob: f47659f85148f537c398ba2077288e8c260ff4a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!$$SHELL$$
name='rvs'
ver='0.7.0'
# Copyright (C) 2009 Luke Shumaker
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# Originally written by Luke Shumaker <lukeshu@sbcglobal.net>.

RVSDIR='$$libdir$$'
REPO=`$RVSDIR/repo`

error() {
	echo "$name: $1" >> /dev/stderr
	exit 1
}

# START OPTION HANDLING #
com=$1;
# END   OPTION HANDLING #
case "$com" in
	'') error 'no command specified';;
	*)
		if [ -f "$RVSDIR/$com" ]; then
			export RVSDIR
			$RVSDIR/$@
			done='yes'
		else
			while read plugin; do
				if [ -f "$RVSDIR/$plugin/$com" ]; then
					export RVSDIR=$RVSDIR/$plugin
					$RVSDIR/$@
					done='yes'
					break
				fi
			done < $REPO/plugins
		fi
		if [ "$done" != 'yes' ]; then
			error "unrecognized command \`$com'"
		fi
	:;;
esac

#args=`getopt -n "$name" -o "${sopt}" -l "${lopt}" -- "$@"`
#if [ $? == 0 ]; then
#	set -- $args
#	while [ $# -gt 0 ]; do
#		case "$1" in
#			-V | --version) mode='version';;
#			-h | -H | -\? | --help) mode='help';;
#			
#			-v | --verbose) volume='-v';;
#			-q | --quiet)   volume='-q';;
#			
#			--) shift; break;;
#		esac
#		shift;
#	done
#else
#	error
#fi