fixed up the script so it correctly outputs the template files to hte tests dir and the src dir

This commit is contained in:
jakeg00dwin 2024-03-01 00:55:06 -08:00
parent ccc9974963
commit 3e60660071
1 changed files with 10 additions and 8 deletions

18
tdd.sh
View File

@ -14,20 +14,22 @@ clear_cmake_cache () {
rm -rf CMakeCache.txt CMakeFiles/
}
does_moule_exist () {
does_module_exist () {
local basename="$1"
if [ -d "tests/$basename"] || [ -d "src/$basename" ]; then
return 1
if [ -d "src/${basename}" ]; then
echo "1"
else
return 0
echo "0"
fi
}
add_new_module () {
read -p "Enter the name of the module:" modname
result=$(does_module_exist "$modname")
if does_module_exist $modname; then
if [ "${result}" -eq "1" ]; then
echo "Module already exists!"
echo "Exiting without changing anything"
exit
@ -48,8 +50,8 @@ add_new_module () {
sed "s/module_name/${modname_cap}/" $MODULE_DIR/module_name.h > $modsrc_dir/${modname}.h
sed "s/module_name/${modname}/" $MODULE_DIR/CMakeLists.txt > $modsrc_dir/CMakeLists.txt
sed "s/module_name/${modname}/" $MODULE_DIR/test_module_name.c > $modsrc_dir/test_${modname}.c
sed "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modsrc_dir/CMakeLists.txt
sed "s/module_name/${modname}/" $MODULE_DIR/test_module_name.c > $modtest_dir/test_${modname}.c
sed "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modtest_dir/CMakeLists.txt
echo "Resulting files/dirs:"
tree -L 2 $modsrc_dir
@ -57,7 +59,7 @@ add_new_module () {
# Now we add the new files to the git tracked files
del_module
#del_module
}
del_module () {