-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_problem.sh
executable file
·34 lines (26 loc) · 988 Bytes
/
init_problem.sh
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
#!/bin/bash
# Quickly initialize a problem directory with templates and helpful files.
# did we get all 4 input parameters we expected?
if [ $# -ne 4 ]
then
echo 'Usage: init_problem.sh "Problem Name" Year "Round" Link'
exit 0
fi
# read input parameters into vars
name=${1:-DefaultProblemName}
year=${2:-DefaultYear}
round=${3:-DefaultRound}
link=${4:-DefaultLink}
date=${5:-`date +"%B, %Y"`}
# make problem directory
mkdir "$name"
# copy templates and helpful files
cp main_template.py "$name/main.py"
cp test_main_template.py "$name/test_main.py"
cp helpful.py "$name/helpful.py"
# fill-in problem info inside the templates
sed -i "" "s/--Problem Name--/$name/g" "$name/main.py" "$name/test_main.py"
sed -i "" "s/--Year--/$year/g" "$name/main.py" "$name/test_main.py"
sed -i "" "s/--Round--/$round/g" "$name/main.py" "$name/test_main.py"
sed -i "" "s,--Link--,$link,g" "$name/main.py" "$name/test_main.py"
sed -i "" "s/--Date--/$date/g" "$name/main.py" "$name/test_main.py"