-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
r2skel
executable file
·56 lines (52 loc) · 1017 Bytes
/
r2skel
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
#!/bin/sh
# TODO: eventually rewrite in Python to support Windows
if [ -L "$0" ]; then
SKELDIR=`dirname $(readlink $0)`
else
SKELDIR=`dirname $0`
fi
WORKDIR="`pwd`"
list_languages() {
(
cd ${SKELDIR} || exit 1
ls -F | grep r2 | grep / | awk -F - '{print $4}' | sed -e 's,/,,' | sort -u
)
}
list_templates() {
(
cd ${SKELDIR} || exit 1
ls -F | grep r2 | grep /$ | sed -e 's,/,,'
)
}
case "$1" in
"-l"|list)
list_templates
;;
"-L"|langs)
list_languages
;;
"-h"|"")
echo "r2skel [-lL] | [template] [new-directory]"
echo "Options:"
echo " -l - list all the available project templates"
echo " -L - list all the languages"
echo "Templates: "
list_templates | xargs -L1 echo ' -'
;;
*)
if [ -n "$2" ]; then
SD="${SKELDIR}/$1"
if [ ! -d "${SD}" ]; then
echo "Invalid skeleton name. See 'r2skel -l'"
exit 1
fi
if [ -d "${2}" ]; then
echo "Target directory already exists"
exit 1
fi
cp -rf "${SD}" "$2"
else
echo "Usage: r2skel [template] [new-directory]"
fi
;;
esac