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() {
149149}
150150
151151
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+
152165# Create year/day directory and cd into it.
153166aoc_create_enter () {
154167 local year=" $1 "
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22# 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.
45
56set -o nounset
67set -o pipefail
@@ -23,11 +24,7 @@ backfill_day() {
2324 local day=" $2 "
2425
2526 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 "
3128 printf " Backfilled %d/%s\n" " $year " " $day " # Print day as %s to preserve leading 0.
3229}
3330
@@ -36,14 +33,12 @@ backfill_days_all() {
3633 paths=$( find . -maxdepth 2 -type d -regex " \./*[0-9]+/[0-9]+" | sort | sed -e ' s|./||' )
3734 for path in $paths ; do
3835 cd " $path " || exit
36+
3937 IFS=" /" read -ra ym <<< " $path"
4038 year=${ym[0]}
4139 day=${ym[1]}
4240
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 "
4742 printf " Backfilled %s\n" " $path "
4843 cd ../..
4944 done
Original file line number Diff line number Diff line change @@ -66,8 +66,7 @@ enter_day() {
6666
6767
6868 aoc_fetch_input " $year " " $day "
69- aoc_create_readme " $year " " $day "
70- aoc_create_instructions_url " $year " " $day "
69+ aoc_create_boilerplates " $year " " $day "
7170}
7271
7372
You can’t perform that action at this time.
0 commit comments