Parcourir la source

:wrench: Make basic replacement working

DricomDragon il y a 2 ans
Parent
commit
939b382dd3
1 fichiers modifiés avec 29 ajouts et 4 suppressions
  1. 29 4
      tools/gd-slide.fish

+ 29 - 4
tools/gd-slide.fish

@@ -4,12 +4,37 @@ set SLIDE_NUM $argv[1]
 set SLIDE_NAME $argv[2]
 set SLIDE_TITLE $argv[3]
 
+set SLIDE_NAME_MARK 'TEMPLATE_NAME'
+set SLIDE_TITLE_MARK 'TEMPLATE_TITLE'
+
 set SLIDES_PATH "../godot/slides"
 set TEMPLATE_FOLDER "$SLIDES_PATH/template"
-set SLIDE_FOLDER "$SLIDES_PATH/$SLIDE_NUM/$SLIDE_NAME"
+set TEMPLATE_FILE "$TEMPLATE_FOLDER/$SLIDE_NAME_MARK.tscn"
+set SLIDE_FOLDER "$SLIDES_PATH/$SLIDE_NUM"
+set SLIDE_FILE "$SLIDE_FOLDER/$SLIDE_NAME"
+
+function gen-res-id
+	echo (head -n 10 /dev/urandom | tr -dc 'a-z' | string shorten -m 5 --char="")
+end
+
+set IDS (gen-res-id) (gen-res-id) (gen-res-id)
+set IDS_MARK 'aaaaa' 'bbbbb' 'ccccc'
+
+echo "Read $TEMPLATE_FILE"
+set CONTENT (cat $TEMPLATE_FILE)
+function get-content
+	printf %s\n $CONTENT
+end
+
+echo "Rename template : $SLIDE_NAME_MARK -> $SLIDE_NAME"
+set CONTENT (get-content | sed -e "s/$SLIDE_NAME_MARK/$SLIDE_NAME/")
 
-echo "Copy $TEMPLATE_FOLDER to $SLIDE_FOLDER"
+echo "Set title : $SLIDE_TITLE_MARK -> $SLIDE_TITLE"
 
-echo "Rename template to $SLIDE_NAME"
+echo "Replace marks"
+for k in (seq 3)
+	echo $k ':' $IDS_MARK[$k] '->' $IDS[$k]
+end
 
-echo "Set title to $SLIDE_TITLE"
+echo "Write to : $SLIDE_FILE"
+get-content