summaryrefslogtreecommitdiff
path: root/scripts/new-file.sh
blob: 9cb65bb2f9eedb632bcdf0824043e267589ba0cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
if [ -z "$1" ] ; then
  printf "Usage: new-file [file basename] (package)\n\n"
  exit 1
fi

fileBasename=$1
if ! [ -z "$2" ] ; then
  filePackage=$2
else
  filePackage=""
fi

fullDate=$(date +"%d %b %y")
year=$(date +"%Y")

printf "//\n\
// %s.h - MrsWatson\n\
// Created by Nik Reiman on %s.\n\
// Copyright (c) %s Teragon Audio. All rights reserved.\n\
//\n\
// Redistribution and use in source and binary forms, with or without\n\
// modification, are permitted provided that the following conditions are met:\n\
//\n\
// * Redistributions of source code must retain the above copyright notice,\n\
//   this list of conditions and the following disclaimer.\n\
// * Redistributions in binary form must reproduce the above copyright notice,\n\
//   this list of conditions and the following disclaimer in the documentation\n\
//   and/or other materials provided with the distribution.\n\
//\n\
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n\
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n\
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n\
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n\
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n\
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n\
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n\
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n\
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n\
// POSSIBILITY OF SUCH DAMAGE.\n\
//\n\
\n\
#ifndef MrsWatson_${fileBasename}_h\n\
#define MrsWatson_${fileBasename}_h\n\
\n\
#endif\n" "$fileBasename" "$fullDate" "$year" > source/$filePackage/$fileBasename.h
printf "Created source/$filePackage/$fileBasename.h\n"

printf "//\n\
// %s.c - MrsWatson\n\
// Created by Nik Reiman on %s.\n\
// Copyright (c) %s Teragon Audio. All rights reserved.\n\
//\n\
// Redistribution and use in source and binary forms, with or without\n\
// modification, are permitted provided that the following conditions are met:\n\
//\n\
// * Redistributions of source code must retain the above copyright notice,\n\
//   this list of conditions and the following disclaimer.\n\
// * Redistributions in binary form must reproduce the above copyright notice,\n\
//   this list of conditions and the following disclaimer in the documentation\n\
//   and/or other materials provided with the distribution.\n\
//\n\
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n\
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n\
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n\
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n\
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n\
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n\
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n\
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n\
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n\
// POSSIBILITY OF SUCH DAMAGE.\n\
//\n\
\n\
#include \"${fileBasename}.h\"\n\
\n" "$fileBasename" "$fullDate" "$year" > source/$filePackage/$fileBasename.c
printf "Created source/$filePackage/$fileBasename.c\n"

printf "#include \"unit/TestRunner.h\"\n\
#include \"$filePackage/$fileBasename.h\"\n\
\n\
\n" > test/$filePackage/${fileBasename}Test.c
printf "Created test/$filePackage/${fileBasename}Test.c\n"