|
|
@ -0,0 +1,35 @@ |
|
|
|
#!/usr/bin/env bash |
|
|
|
|
|
|
|
if test ! -f "project.yml"; then |
|
|
|
echo -e "no project.yml was found -> generation failed\nplease run this command from the root of the project directory" |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
if test -z $1; then |
|
|
|
echo "no file path was provided -> generation failed" |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
name="$(basename $1)" |
|
|
|
mkdir -p "test/$(dirname $1)" |
|
|
|
mkdir -p "src/$(dirname $1)" |
|
|
|
|
|
|
|
testcontent="#include \"unity.h\"\n#include \"$1.h\"\n\nvoid setUp(void){}\nvoid tearDown(void){}" |
|
|
|
filecontent="#include \"$name.h\"" |
|
|
|
headercontent="#ifndef ${name^^}_H\n#define ${name^^}_H\n\n\n#endif" |
|
|
|
|
|
|
|
if test -e "test/test_$1.c"; then |
|
|
|
echo "the file test/test_$1.c already exists -> generation failed" |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
if test -e "src/$1.c"; then |
|
|
|
echo "the file src/$1.c already exists -> generation failed" |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
if test -e "src/$1.h"; then |
|
|
|
echo "the file src/$1.h already exists -> generation failed" |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
echo -e $testcontent > "test/test_$1.c" |
|
|
|
echo -e $filecontent > "src/$1.c" |
|
|
|
echo -e $headercontent > "src/$1.h" |