From 10dce09e4dbcee16c8daad16b3425893c92144af Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 21 May 2018 16:16:07 +0200 Subject: [PATCH] add proj gen script --- script/add_project.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 script/add_project.sh diff --git a/script/add_project.sh b/script/add_project.sh new file mode 100755 index 0000000..5205581 --- /dev/null +++ b/script/add_project.sh @@ -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=\"\"" "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 +# . -> -> base +sed -i "s//\ \.\ ->\ $base_relations/g" "src/proj/$name" +# +sed -i "s//$name/g" "src/proj/$name" +sed -i "s//$base/g" "src/proj/$name" + +#open +editor "src/proj/$name"