-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.zsh
executable file
·77 lines (61 loc) · 2.07 KB
/
init.zsh
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
#!/bin/zsh
# Check script options
if [[ "$#" -lt 1 ]]; then
echo "Usage: ./init.zsh MyAddonName [folder]"
exit 1
fi
if [[ $(echo "$1" | head -c 1) == "-" ]]; then
echo "Usage: ./init.zsh MyAddonName [folder]"
exit 1
fi
# Check script necessary tools : sed, perl, perl-rename
PERL=$(command -v perl)
if [[ ! -x "$PERL" ]] ; then
echo "Install perl"
exit 1
fi
RENAME=$(command -v perl-rename)
if [[ ! -x "$RENAME" ]] ; then
RENAME=$(command -v rename)
fi
RENAME_KIND=$($RENAME --help | grep -i PERLEXPR)
if [[ "$OSTYPE" != "darwin"* ]]; then
if [[ "$RENAME_KIND" == "" ]]; then
echo "Install perl-rename (sometimes called just 'rename')"
exit 1
fi
fi
SED=/usr/bin/sed
if [[ "$OSTYPE" == "darwin"* ]]; then
if ! [[ -x "$(command -v gsed)" ]]; then
echo "Install gnu-sed"
exit 1
fi
SED=$(command -v gsed)
fi
ADDON="$1"
ADDON_LC=$(echo $ADDON | $PERL -ne 'print lc')
ADDON_LC_DASHES=$(echo $ADDON_LC | sed 's/_/-/g')
ADDON_DIR="$PWD"
if [[ "x$2" != "x" ]]; then
TARGET_FOLDER="$2"
mkdir -p "$TARGET_FOLDER"
cp -rf * "$TARGET_FOLDER/"
cd "$TARGET_FOLDER"
else
TARGET_FOLDER="$PWD"
fi
mv "MyAvndEffect" "$ADDON"
$RENAME "s/my_avnd_effect/$ADDON_LC/" **/*.{hpp,cpp,txt}
$RENAME "s/MyAvndEffect/$ADDON/" **/*.{hpp,cpp,txt}
$SED -i "s/my_avnd_effect/$ADDON_LC/g" **/*.{hpp,cpp,txt}
$SED -i "s/MyAvndEffect/$ADDON/g" **/*.{hpp,cpp,txt} release.sh
$SED -i "s/my-avnd-effect/$ADDON_LC_DASHES/g" **/*.{hpp,cpp,txt} release.sh
echo -e "# $ADDON\nA new and wonderful [ossia score](https://ossia.io) add-on" > README.md
find . -name '*.hpp' -exec $PERL -pi -e 'chomp(my $uidgen = `uuidgen`);s|00000000-0000-0000-0000-000000000000|$uidgen|gi' {} \;
find . -name '*.cpp' -exec $PERL -pi -e 'chomp(my $uidgen = `uuidgen`);s|00000000-0000-0000-0000-000000000000|$uidgen|gi' {} \;
find . -name '*.json' -exec $PERL -pi -e 'chomp(my $uidgen = `uuidgen`);s|00000000-0000-0000-0000-000000000000|$uidgen|gi' {} \;
find . -name '*.txt' -exec $PERL -pi -e 'chomp(my $uidgen = `uuidgen`);s|00000000-0000-0000-0000-000000000000|$uidgen|gi' {} \;
rm -rf .git
git init
rm init.sh init.zsh