forked from jskenney/calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewmtg.sh
More file actions
executable file
·128 lines (121 loc) · 3.74 KB
/
newmtg.sh
File metadata and controls
executable file
·128 lines (121 loc) · 3.74 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# Course: General Course
# Role: Course Coordinator
# Author: LCDR C. W. Hoffmeister
# Description: bash script to setup material for a meeting
dir=class/ # Default to class directory
# Displays script usage information
function usage () {
echo "usage: newmtg <meeting type> <meeting name>"
echo "Note: Script designed to use calendar-core project (see https://github.com/jskenney/calendar-core)"
echo " meeting types: { class, exam, info, lab, quiz, resources, review }"
if [ -d calendar-core ] ; then
echo " meeting name: Use calendar-core project naming convention"
else
echo " meeting name: (it's your jeep)"
fi
}
# Copy core type specified files to target directory
function copyCoreFiles () {
if [ -f .index-template.html ] && [ ! -f "${1}/index.html" ] ; then # Meeting template
cp .index-template.html "${1}/index.html"
fi
if [ -f .learnOuts-template.html ] && [ ! -f "${1}/learnOuts.html" ] ; then # Meeting template
cp .learnOuts-template.html "${1}/learnOuts.html"
fi
}
# Copy example files to target directory
function copyExampleFiles () {
if (( ${#} == 1 )) ; then # Correct number of arguments
# TODO: Convert to generic loop
if [ -f .example-template.c ] && [ ! -f "${1}/example.c" ] ; then # example-00.c template exists
cp .example-template.c "${1}/example.c"
fi
fi
}
if (( ${#} != 2 )) ; then # Incorrect number of arguments
usage
elif (( ${#} == 2 )) ; then # Correct number of arguments
case ${1} in # Type of meeting to create
class ) # Class Meeting
dir="class/${2}"
if [ ! -d "${dir}" ] ; then
mkdir -p "${dir}"
fi
# Core files for meeting type
copyCoreFiles "${dir}"
if [ -f .notes-template.pptx ] && [ ! -f "${dir}/notes.pptx" ] ; then # notes-template.pptx template exists
cp .notes-template.pptx "${dir}/notes.pptx"
fi
if [ -f .assign-template.docx ] && [ ! -f "${1}/assign.docx"] ; then
cp .assign-template.docx "${1}/assign.docx"
fi
# Example files
copyExampleFiles "${dir}"
;;
lab ) # Lab Meeting
dir="lab/${2}"
if [ ! -d "${dir}" ] ; then
mkdir -p "${dir}"
fi
# Core files for meeting type
copyCoreFiles "${dir}"
if [ -f .prgm-template.docx ] && [ ! -f "${dir}/pgrm.docx" ] ; then # prgm-template.docx template exists
cp .prgm-template.docx "${dir}/prgm.docx"
fi
copyExampleFiles "${dir}"
;;
quiz )
dir="quiz/${2}"
if [ ! -d "${dir}" ] ; then
mkdir -p "${dir}"
fi
# Core files for meeting type
copyCoreFiles "${dir}"
if [ -f .assign-template.docx ] && [ ! -f "${dir}/quiz.docx" ] ; then # assign-template.docx template exists
cp -f .assign-template.docx "${dir}/quiz.docx"
fi
;;
exam ) # Exam meeting
dir="exam/${2}"
if [ ! -d "${dir}" ] ; then
mkdir -p "${dir}"
fi
# Core files for meeting type
if [ -f .exm-template.docx ] && [ ! -f "${dir}/assign.docx" ] ; then # exm-template.docx template exists
cp -f .exm-template.docx "${dir}/assign.docx"
fi
copyCoreFiles "${dir}"
;;
info )
dir="info/${2}"
if [ ! -d "${dir}" ] ; then
mkdir -p "${dir}"
fi
if [ -f .index-template.html ] && [ ! -f "${dir}/index.html" ] ; then # Meeting template
cp .index-template.html "${dir}/index.html"
fi
;;
resources )
dir="resources/${2}"
if [ ! -d "${dir}" ] ; then
mkdir -p "${dir}"
fi
if [ -f .index-template.html ] && [ ! -f "${dir}/index.html" ] ; then # Meeting template
cp .index-template.html "${dir}/index.html"
fi
;;
review )
dir="review/${2}"
if [ ! -d "${dir}" ] ; then
mkdir -p "${dir}"
fi
copyCoreFiles "${dir}"
;;
*) # Incorrect meeting type
echo ${usage}
;;
esac
# Course work revision control system
git status -s 2> /dev/null && git add "${dir}" # Using git for revision control
fi