Added lanuage selection menu and functions for the add new module
option in the main menu.
This commit is contained in:
parent
b3d33c2db9
commit
f047a88629
1 changed files with 51 additions and 5 deletions
56
otto.sh
56
otto.sh
|
@ -117,6 +117,7 @@ git_remove_module () {
|
||||||
|
|
||||||
|
|
||||||
add_new_module () {
|
add_new_module () {
|
||||||
|
|
||||||
read -p "Enter the name of the module:" modname
|
read -p "Enter the name of the module:" modname
|
||||||
|
|
||||||
result=$(does_module_exist "$modname")
|
result=$(does_module_exist "$modname")
|
||||||
|
@ -137,7 +138,35 @@ add_new_module () {
|
||||||
|
|
||||||
#copy the template files.
|
#copy the template files.
|
||||||
echo "copying & customizing template files..."
|
echo "copying & customizing template files..."
|
||||||
|
|
||||||
|
echo "Select an option:"
|
||||||
|
echo "1.) Add a C module"
|
||||||
|
echo "2.) Add a C++ module"
|
||||||
|
|
||||||
|
read -P "choice:" lanuage_selection
|
||||||
|
|
||||||
|
case $lanuage_selection in
|
||||||
|
1)
|
||||||
|
echo "You selected Option 1"
|
||||||
|
add_c_mdoule
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
echo "You selected Option 2"
|
||||||
|
add_cpp_module
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid Choice!\nExiting..."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Now we add the new files to the git tracked files
|
||||||
|
git_add_module "${modname}"
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
add_c_mdoule () {
|
||||||
|
|
||||||
sed "s/module_name/${modname}/" $MODULE_DIR/module_name.c > $modsrc_dir/${modname}.c
|
sed "s/module_name/${modname}/" $MODULE_DIR/module_name.c > $modsrc_dir/${modname}.c
|
||||||
sed -i'' "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.c
|
sed -i'' "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.c
|
||||||
|
|
||||||
|
@ -155,13 +184,30 @@ add_new_module () {
|
||||||
echo "Resulting files/dirs:"
|
echo "Resulting files/dirs:"
|
||||||
tree -L 2 $modsrc_dir
|
tree -L 2 $modsrc_dir
|
||||||
tree -L 2 $modtest_dir
|
tree -L 2 $modtest_dir
|
||||||
|
|
||||||
# Now we add the new files to the git tracked files
|
|
||||||
git_add_module "${modname}"
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_cpp_module () {
|
||||||
|
|
||||||
|
sed "s/module_name/${modname}/" $MODULE_DIR/module_name.cpp > $modsrc_dir/${modname}.cpp
|
||||||
|
sed -i'' "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.cpp
|
||||||
|
|
||||||
|
sed "s/module_name/${modname_cap}/" $MODULE_DIR/module_name.h > $modsrc_dir/${modname}.h
|
||||||
|
sed -i'' "3s/todays_date/$(date +%Y)/" $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.cpp > $modtest_dir/test_${modname}.cpp
|
||||||
|
sed "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modtest_dir/CMakeLists.txt
|
||||||
|
|
||||||
|
# Add the module to the cmake lists files.
|
||||||
|
add_module_to_cmakes "${modname}"
|
||||||
|
|
||||||
|
echo "Resulting files/dirs:"
|
||||||
|
tree -L 2 $modsrc_dir
|
||||||
|
tree -L 2 $modtest_dir
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
del_module () {
|
del_module () {
|
||||||
read -p "Enter the name of the module:" modname
|
read -p "Enter the name of the module:" modname
|
||||||
|
|
Loading…
Add table
Reference in a new issue