add proj gen script
This commit is contained in:
parent
f77f690751
commit
10dce09e4d
34
script/add_project.sh
Executable file
34
script/add_project.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
#check param
|
||||
[ -z "$1" ] && { echo "$0 \"name\" [base]"; exit 1; }
|
||||
name="$1"
|
||||
base="$2"
|
||||
|
||||
#gen project
|
||||
cp "doc/proj-head" "src/proj/$name"
|
||||
|
||||
#set base_relations
|
||||
if [ -z "$base" ]; then
|
||||
base_relations="base"
|
||||
base="base"
|
||||
sed -i "/project_relation=/c\project_relation=\"<PROJECT_NAME>\"" "src/proj/$name"
|
||||
else
|
||||
[ -f "src/proj/$base" ] || {
|
||||
echo "BASE: $base dont exist"
|
||||
exit 1
|
||||
}
|
||||
#get base of $base
|
||||
base_base=`grep '# . ->' src/proj/$base`
|
||||
base_relations=`echo $base_base | sed "s/#\ \./$base/g"`
|
||||
fi
|
||||
|
||||
## replace strings
|
||||
# . -> <PROJECT_PARENT> -> base
|
||||
sed -i "s/<project_relation>/\ \.\ ->\ $base_relations/g" "src/proj/$name"
|
||||
#<PROJECT_NAME>
|
||||
sed -i "s/<PROJECT_NAME>/$name/g" "src/proj/$name"
|
||||
sed -i "s/<BASE>/$base/g" "src/proj/$name"
|
||||
|
||||
#open
|
||||
editor "src/proj/$name"
|
Loading…
Reference in New Issue
Block a user