-
Notifications
You must be signed in to change notification settings - Fork 1
/
rdm
executable file
·95 lines (84 loc) · 2.3 KB
/
rdm
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
die () {
retcode=$?
echo "ERROR: $1" >&2
exit $retcode
}
program="$0"
arg=
make=
ninja=
link=
help=
while [ $# -gt '0' -a -z "$arg" ]; do
if [ "$1" = "--ninja" ]; then
ninja=1
shift
elif [ "$1" = "--make" ]; then
make=1
shift
elif [ "$1" = "--link" ]; then
link=1
shift
elif [ "$1" = "--help" -o "$1" = "-h" ]; then
help=1
shift
else
arg="$1"
fi
done
if [ -n "$help" ]; then
echo "Usage:"
echo
echo " rdm [--make] [--link] [-h|--help] <command> <arguments>"
echo
echo " --make Build the tool with make before executing it"
echo " --ninja Build the tool with ninja before executing it"
echo " --link Make a symbolic link for the command to the current"
echo " working directory"
echo " [-h|--help] Print his help"
echo " <command> The rdm-<command> to execute"
echo " <arguments> Arguments that are to be passed on to rdm-<command>"
echo
exit 2
fi
if [ $# = '0' ]; then
echo "error: rdm require at least one argument" >&2
exit 2
fi
if [ -n "$make" ]; then
pushd $(searchdir source/rdm-"$1") >/dev/null || die "Did not find executable directory"
make 2>/dev/null >/dev/null || die "Failed to compile"
popd
fi
if [ -n "$ninja" ]; then
pushd $(searchdir .) >/dev/null || die "Did not find executable directory"
ninja source/rdm-"$1"/all 2>/dev/null >/dev/null || die "Failed to compile"
popd
fi
dir=$(searchdir source/rdm-"$1" 2>/dev/null)
cmd=rdm-"$1"
if [ $? != 0 ]; then
echo "error: RDM command not found: rdm-""$1" >&2
exit 2
fi
if [ -x "${dir}$cmd" ]; then
build_type=
elif [ -x "${dir}Debug/$cmd" ]; then
build_type=Debug/
elif [ -x "${dir}Release/$cmd" ]; then
build_type=Release/
elif [ -x "${dir}RelWithDebInfo/$cmd" ]; then
build_type=RelWithDebInfo/
elif [ -x "${dir}MinSizeRel/$cmd" ]; then
build_type=MinSizeRel/
else
die "$cmd not found"
fi
if [ -n "$link" ]; then
ln -s "$dir$build_type$cmd" "$cmd" >/dev/null || die "Did not find executable directory"
else
echo "cd $(pathdir) &&" "$dir$build_type$cmd" -q "$@"
shift
rlwrap --prompt-colour=red --file=/home/sj/bin/rdm-sql.completion "$dir$build_type$cmd" -q "$@"
fi