-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenDay.sh
49 lines (35 loc) · 924 Bytes
/
genDay.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Error: no dayNumber given."
exit 1
fi
dayNumber=$1
if ! [[ "$dayNumber" =~ ^[0-9]+$ ]] || [ "$dayNumber" -lt 1 ] || [ "$dayNumber" -gt 25 ]; then
echo "Error: give number from 1 to 25."
exit 1
fi
directory="src/solutions/day${dayNumber}"
if [ -d "$directory" ]; then
echo "Error: directory $directory already exists."
exit 1
fi
mkdir "$directory"
file="${directory}/Day${dayNumber}.java"
touch "$file"
sample="${directory}/sample.txt"
touch "$sample"
input="${directory}/input.txt"
touch "$input"
cat <<EOL > "$file"
package solutions.day${dayNumber};
import solutions.Solution;
import solutions.SolutionResponse;
import java.util.Scanner;
public class Day${dayNumber} implements Solution {
public SolutionResponse solve(Scanner inputScanner) {
return new SolutionResponse(0, 0);
}
}
EOL
git add -A
echo "Created day $dayNumber."