blob: a56311558278cbfd4f22f7d71a3e798ea5e7eeb8 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/bin/bash
#
# Templater: setup or configure a new code project.
#
# Copyright (C) 2017 Silvio Rhatto - rhatto at riseup.net
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Parameters
NAME="templater"
PROGRAM="$0"
BASENAME="`basename $0`"
PROJECT="$1"
shift
MODULES="$*"
CWD="`pwd`"
# Set shared files location
if [ -e "`dirname $(readlink -f $0)`/share/$NAME" ]; then
# Development or local installation layout
SHARE="`dirname $(readlink -f $0)`/share/$NAME"
else
# System installation layout
SHARE="`dirname $(readlink -f $0)`/../share/$NAME"
fi
# Include basic functions
source $SHARE/templater/functions || exit 1
# Syntax check
if [ -z "$PROJECT" ]; then
echo "$BASENAME: create a new project folder and/or setup helper utilities"
echo ""
echo "usage: $BASENAME <path> [<module1> ... <moduleN>]"
echo ""
echo "examples":
echo ""
echo -e "\t templater myproject git ikiwiki # adds git and ikiwiki config into myproject"
echo -e "\t templater . pelican # add pelican config into the current folder"
echo ""
echo "available modules:"
echo ""
#__templater_implementations | xargs -L 6 | column -t -c 6 | sed -e 's/^/\t/'
for module in `__templater_implementations`; do
echo -e "\t $module: `cat $SHARE/$module/description`"
done
echo ""
exit 1
fi
# Initialize
__templater_init
# Go to project folder
cd $PROJECT &> /dev/null
# Setup modules
if [ -z "$MODULES" ]; then
for project in `__templater_implementations`; do
__templater_ask $project
done
else
for module in $MODULES; do
if `__templater_implementations | grep -q "^$module"`; then
#templater_$module
$SHARE/$module/setup $SHARE
else
__templater_echo "No such module $module, skipping"
fi
done
fi
# Teardown
cd $CWD
__templater_echo "Done processing the project :)"
|