blob: 494c86f174e102c9a3929ec64a06ccf42103b208 (
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
|
#!/bin/sh -eu
if [ "${1:-}" ]; then
_lang="$1"
fi
if [ "${2:-}" ]; then
_year="$2"
else
_year=$( date +%Y )
fi
### FUNCTION ##################################################################
rust() {
rust_dir="$1"
(
printf '%s\n%s\n' '[workspace]' 'members = ['
for day in $( seq 1 25 ); do
printf '# "day%02d",\n' "${day}"
done
echo ']'
) > "${rust_dir}/Cargo.toml"
unset rust_dir
}
### MAIN ######################################################################
_dir="$( pwd )/${_year}"
if ! [ -d "${_dir}" ]; then
read -p "Create directory '${_dir}'?: " _input
case "${_input}" in
'y' | 'Y')
mkdir "${_dir}"
;;
*)
echo 'Okay, not doing anything then.'
exit 0
;;
esac
unset _input
fi
[ "${_lang:-}" ] || read -p "Implementation language for '${_year}'?: " _lang
if ! [ -d "${_dir}/${_lang}" ]; then
read -p "Create directory '${_dir}/${_lang}'?: " _input
case "${_input}" in
'y' | 'Y')
mkdir "${_dir}/${_lang}"
;;
*)
echo 'Okay, not doing that then.'
exit 0
;;
esac
unset _input
fi
read -p "Run '${_lang}(\"${_dir}/${_lang}\")'?: " _input
case "${_input}" in
'y' | 'Y')
${_lang} "${_dir}/${_lang}"
;;
*)
echo 'Okay, not doing that then.'
exit 0
;;
esac
unset _input
unset _dir _lang _year
|