fix: make control flow

This commit is contained in:
alexchao26
2021-12-08 21:37:27 -05:00
parent 5de262fb6d
commit c625101870
+8 -23
View File
@@ -9,43 +9,28 @@ check-aoc-cookie: ## ensures $AOC_SESSION_COOKIE env var is set
@ test $${AOC_SESSION_COOKIE?env var not set} @ test $${AOC_SESSION_COOKIE?env var not set}
skeleton: ## make skeleton main(_test).go files, optional: $DAY and $YEAR skeleton: ## make skeleton main(_test).go files, optional: $DAY and $YEAR
# Check DAY and YEAR are both set
@ if [[ -n $$DAY && -n $$YEAR ]]; then \ @ if [[ -n $$DAY && -n $$YEAR ]]; then \
go run scripts/cmd/skeleton/main.go -day $(DAY) -year $(YEAR); \ go run scripts/cmd/skeleton/main.go -day $(DAY) -year $(YEAR) ; \
fi elif [[ -n $$DAY ]]; then \
# DAY only, use current year
@ if [[ -n $$DAY ]]; then \
go run scripts/cmd/skeleton/main.go -day $(DAY); \ go run scripts/cmd/skeleton/main.go -day $(DAY); \
fi else \
# if DAY or YEAR are not set, allow the go binary to default to today
@ if [[ -z $$DAY || -z $$YEAR ]]; then \
go run scripts/cmd/skeleton/main.go; \ go run scripts/cmd/skeleton/main.go; \
fi fi
input: check-aoc-cookie ## get input, requires $AOC_SESSION_COOKIE, optional: $DAY and $YEAR input: check-aoc-cookie ## get input, requires $AOC_SESSION_COOKIE, optional: $DAY and $YEAR
# Check DAY and YEAR are both set
@ if [[ -n $$DAY && -n $$YEAR ]]; then \ @ if [[ -n $$DAY && -n $$YEAR ]]; then \
go run scripts/cmd/input/main.go -day $(DAY) -year $(YEAR) -cookie $(AOC_SESSION_COOKIE); \ go run scripts/cmd/input/main.go -day $(DAY) -year $(YEAR) -cookie $(AOC_SESSION_COOKIE); \
fi elif [[ -n $$DAY ]]; then \
# DAY only, use current year
@ if [[ -n $$DAY ]]; then \
go run scripts/cmd/input/main.go -day $(DAY) -cookie $(AOC_SESSION_COOKIE); \ go run scripts/cmd/input/main.go -day $(DAY) -cookie $(AOC_SESSION_COOKIE); \
fi else \
# if DAY or YEAR are not yet, allow the go binary to default to today
@ if [[ -z $$DAY || -z $$YEAR ]]; then \
go run scripts/cmd/input/main.go -cookie $(AOC_SESSION_COOKIE); \ go run scripts/cmd/input/main.go -cookie $(AOC_SESSION_COOKIE); \
fi fi
prompt: check-aoc-cookie ## get prompt, requires $AOC_SESSION_COOKIE, optional: $DAY and $YEAR prompt: check-aoc-cookie ## get prompt, requires $AOC_SESSION_COOKIE, optional: $DAY and $YEAR
# Check DAY and YEAR are both set
@ if [[ -n $$DAY && -n $$YEAR ]]; then \ @ if [[ -n $$DAY && -n $$YEAR ]]; then \
go run scripts/cmd/prompt/main.go -day $(DAY) -year $(YEAR) -cookie $(AOC_SESSION_COOKIE); \ go run scripts/cmd/prompt/main.go -day $(DAY) -year $(YEAR) -cookie $(AOC_SESSION_COOKIE); \
fi elif [[ -n $$DAY ]]; then \
# DAY only, use current year go run scripts/cmd/prompt/main.go -day $(DAY) -cookie $(AOC_SESSION_COOKIE); \
@ if [[ -n $$DAY ]]; then \ else \
go run scripts/cmd/prompt/main.go -day $(DAY) -year $(YEAR) -cookie $(AOC_SESSION_COOKIE); \
fi
# if DAY or YEAR are not yet, allow the go binary to default to today
@ if [[ -z $$DAY || -z $$YEAR ]]; then \
go run scripts/cmd/prompt/main.go -cookie $(AOC_SESSION_COOKIE); \ go run scripts/cmd/prompt/main.go -cookie $(AOC_SESSION_COOKIE); \
fi fi