2021-2022/tools/scripts/new_sequence.sh

87 lines
1.8 KiB
Bash
Raw Normal View History

#!/bin/bash
display_result() {
dialog --title "$1" \
--no-collapse \
--msgbox "$result" 0 0
}
exec 3>&1
date=$(dialog --calendar "Date" 0 0 2>&1 1>&3 | awk -F "/" '{print $3"-"$2"-"$1}')
exec 3>&-
exec 3>&1
selection=$(dialog \
--backtitle "Création d'une nouvelle séquence: Classe" \
--title "Menu" \
--clear \
--cancel-label "Exit" \
--menu "Choisir un niveau:" 0 0 4 \
"1" "2nd" \
"2" "Enseignements Scientifique" \
"3" "4e" \
"4" "Technologique" \
2>&1 1>&3)
exec 3>&-
case $selection in
1 )
tribe="2nd"
;;
2 )
tribe="EnseignementsScientifique"
;;
3 )
tribe="4e"
;;
4 )
tribe="Technologique"
;;
esac
exec 3>&1
cd $tribe
existing_seq=$(ls -d */)
nbr_seq=$(echo $existing_seq | wc -w)
2021-09-06 13:04:10 +00:00
next_seq_number=$(expr $nbr_seq)
title=$(dialog \
--inputbox "Séquences trouvée\n${existing_seq/ /\n} \nNom de la nouvelle sequence (n°$next_seq_number)" \
0 0 \
2>&1 1>&3)
exec 3>&-
cd ..
exec 3>&1
summary=$(dialog \
--inputbox "Résumé de la séquence" \
0 0 \
2>&1 1>&3)
exec 3>&-
## ajouter les tags
exec 3>&1
tags=$(dialog \
--inputbox "Liste des tags séparés par une virgule" \
0 0 \
2>&1 1>&3)
exec 3>&-
sequence_path=$tribe/$(printf "%02d" $next_seq_number)_${title// /_}/
mkdir -p $sequence_path
export title=$title
export title_under=${title//?/#}
export author='Benjamin Bertrand'
export date=$date
export tribe=$tribe
export tags=$tags
export summary=$summary
envsubst < ./tools/skeleton/sequence/index.rst > $sequence_path/index.rst
envsubst < ./tools/skeleton/sequence/exercises.tex > $sequence_path/exercises.tex
envsubst < ./tools/skeleton/sequence/1E.tex > $sequence_path/1E.tex
envsubst < ./tools/skeleton/sequence/1B.tex > $sequence_path/1B.tex