-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
49 lines (37 loc) · 1.43 KB
/
Copy pathjustfile
File metadata and controls
49 lines (37 loc) · 1.43 KB
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
#!/usr/bin/env just --justfile
default: help
help:
@echo "Usage: just [command]. To create a new day, run 'just new DAY=XX'"
# Command to create a new day. This will copy the template over to a new
# file, update a few funciton names accordingly, then add this module to
# the puzzles crate.
# Create a new day from the template
new DAY:
cp src/puzzles/template.rs "src/puzzles/day{{DAY}}.rs"
echo "pub mod day{{DAY}};" >> src/puzzles.rs
sed -i '' -e 's/day_0/day_{{DAY}}/g' "src/puzzles/day{{DAY}}.rs"
sed -i '' -e 's/day0/day{{DAY}}/g' "src/puzzles/day{{DAY}}.rs"
sed -i '' -e 's/get_puzzle_input(0/get_puzzle_input({{DAY}}/g' "src/puzzles/day{{DAY}}.rs"
git co -b "day{{DAY}}"
cargo run -- input "{{DAY}}"
git add "src/puzzles/day{{DAY}}.rs" "src/puzzles.rs" "inputs/day_{{DAY}}.txt"
git commit -m "Add day {{DAY}} start"
@echo "Day {{DAY}} created in a new git branch."
# test a specific day
test DAY:
K9_UPDATE_SNAPSHOTS=1 cargo test "day{{DAY}}"
# test part 1 example
p1e DAY:
K9_UPDATE_SNAPSHOTS=1 cargo test "day{{DAY}}_p1_example"
# test part 1 real
p1 DAY:
K9_UPDATE_SNAPSHOTS=1 cargo test "day{{DAY}}_p1_real"
# test part 2 example
p2e DAY:
K9_UPDATE_SNAPSHOTS=1 cargo test "day{{DAY}}_p2_example"
# test part 2 real
p2 DAY:
K9_UPDATE_SNAPSHOTS=1 cargo test "day{{DAY}}_p2_real"
# run and watch all tests
watch DAY:
K9_UPDATE_SNAPSHOTS=1 cargo watch -c -x "test day{{DAY}}"