-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
40 lines (34 loc) · 812 Bytes
/
init.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
#!/bin/bash
new_name="ab-c"
usage() {
echo "Usage: $0 [-n|--new_name[=]NEW_NAME]"
echo " -n, --new_name[=]NEW_NAME Set the new project name (default: ab-c)"
}
parse_args() {
while [ "$#" -gt 0 ]; do
case $1 in
-n | --new_name | --new_name=*)
new_name="${1#*=}"
[ "$new_name" = "$1" ] && {
shift
new_name="$1"
}
;;
-h | --help)
usage
exit 0
;;
*)
echo "Unknown option: $1"
usage
exit 1
;;
esac
shift
done
}
parse_args "$@"
short_new_name=$(echo $new_name | sed 's/-//g')
find . -depth -name "*cpptemplate*" -execdir rename "s/cpptemplate/$short_new_name/g" {} +
find . -type f -exec sed -i "s/cpptemplate/$short_new_name/g" {} +
find . -type f -exec sed -i "s/cpp-template/$new_name/g" {} +