forked from qgis/QGIS
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcustomwidget_create.sh
executable file
·45 lines (35 loc) · 1.26 KB
/
customwidget_create.sh
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
#!/usr/bin/env bash
# This script automatically creates custom widget plugin for a given widget class name.
# Use customwidget_create.sh QgsColorButton to create QgsColorButtonPlugin files.
# It uses author name and email from git config.
# Denis Rouzaud
# 13.01.2016
set -e
# GNU prefix command for mac os support (gsed, gsplit)
GP=
if [[ "$OSTYPE" =~ darwin* ]]; then
GP=g
fi
CLASSNAME=$1
TODAY=$(date '+%d.%m.%Y')
YEAR=$(date '+%Y')
AUTHOR=$(git config user.name)
EMAIL=$(git config user.email)
CLASSUPPER="${CLASSNAME^^}"
CLASSLOWER="${CLASSNAME,,}"
CLASSWITHOUTQGS=$(${GP}sed 's/^Qgs//' <<< ${CLASSNAME})
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
declare -a EXT=("cpp" "h")
for i in "${EXT[@]}"
do
DESTFILE=$DIR/../src/customwidgets/${CLASSLOWER}plugin.$i
cp "$DIR"/customwidget."$i".template "$DESTFILE"
${GP}sed -i "s/%DATE%/${TODAY}/g" ${DESTFILE}
${GP}sed -i "s/%YEAR%/${YEAR}/g" ${DESTFILE}
${GP}sed -i "s/%AUTHOR%/${AUTHOR}/g" ${DESTFILE}
${GP}sed -i "s/%EMAIL%/${EMAIL}/g" ${DESTFILE}
${GP}sed -i "s/%CLASSUPPERCASE%/${CLASSUPPER}/g" ${DESTFILE}
${GP}sed -i "s/%CLASSLOWERCASE%/${CLASSLOWER}/g" ${DESTFILE}
${GP}sed -i "s/%CLASSMIXEDCASE%/${CLASSNAME}/g" ${DESTFILE}
${GP}sed -i "s/%CLASSWITHOUTQGS%/${CLASSWITHOUTQGS}/g" ${DESTFILE}
done