File tree Expand file tree Collapse file tree 3 files changed +19
-12
lines changed Expand file tree Collapse file tree 3 files changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,19 @@ aoc_create_input_script() {
149
149
}
150
150
151
151
152
+ # Create boilerplate files for a year/day.
153
+ # NOTE only generate files that should be checked in here. Especially not
154
+ # aoc_fetch_input as the backfill script should not spam curl(1)s.
155
+ aoc_create_boilerplates () {
156
+ local year=" $1 "
157
+ local day=" $2 "
158
+
159
+ aoc_create_readme " $year " " $day "
160
+ aoc_create_instructions_url " $year " " $day "
161
+ aoc_create_input_script " $year " " $day "
162
+ }
163
+
164
+
152
165
# Create year/day directory and cd into it.
153
166
aoc_create_enter () {
154
167
local year=" $1 "
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
# Backfill boilerplate files for like README.md, instructions.url etc. for a given year and day.
3
- # Run this when changing the template in aoc_create_readme()
3
+ # NOTE Run this when changing the template in aoc_create_readme()
4
+ # NOTE Make sure this script does not call aoc_fetch_input(), as it should not spam curl(1) to AoC server.
4
5
5
6
set -o nounset
6
7
set -o pipefail
@@ -23,11 +24,7 @@ backfill_day() {
23
24
local day=" $2 "
24
25
25
26
aoc_create_enter " $year " " $day " # Might not exist yet, as compared to backfill_days_all().
26
-
27
- aoc_create_readme " $year " " $day "
28
- aoc_create_instructions_url " $year " " $day "
29
- aoc_create_input_script " $year " " $day "
30
-
27
+ aoc_create_boilerplates " $year " " $day "
31
28
printf " Backfilled %d/%s\n" " $year " " $day " # Print day as %s to preserve leading 0.
32
29
}
33
30
@@ -36,14 +33,12 @@ backfill_days_all() {
36
33
paths=$( find . -maxdepth 2 -type d -regex " \./*[0-9]+/[0-9]+" | sort | sed -e ' s|./||' )
37
34
for path in $paths ; do
38
35
cd " $path " || exit
36
+
39
37
IFS=" /" read -ra ym <<< " $path"
40
38
year=${ym[0]}
41
39
day=${ym[1]}
42
40
43
- aoc_create_readme " $year " " $day "
44
- aoc_create_instructions_url " $year " " $day "
45
- aoc_create_input_script " $year " " $day "
46
-
41
+ aoc_create_boilerplates " $year " " $day "
47
42
printf " Backfilled %s\n" " $path "
48
43
cd ../..
49
44
done
Original file line number Diff line number Diff line change @@ -66,8 +66,7 @@ enter_day() {
66
66
67
67
68
68
aoc_fetch_input " $year " " $day "
69
- aoc_create_readme " $year " " $day "
70
- aoc_create_instructions_url " $year " " $day "
69
+ aoc_create_boilerplates " $year " " $day "
71
70
}
72
71
73
72
You can’t perform that action at this time.
0 commit comments