From e15f38de0063023f9fa7d914734ca768f4cf0836 Mon Sep 17 00:00:00 2001 From: mcbloch Date: Fri, 1 Dec 2023 13:24:17 +0100 Subject: [PATCH] add args checking and feedback --- 2023/complete-benchmark | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/2023/complete-benchmark b/2023/complete-benchmark index 7204b36..d527bec 100755 --- a/2023/complete-benchmark +++ b/2023/complete-benchmark @@ -1,14 +1,32 @@ #!/bin/sh + +help() +{ + echo $0 [day] [part] +} + +if ! test -n "$1"; then + echo "'day' is not given" >&2 + help + exit 1 +fi day="$(printf '%02d' ${1##0})" + +if ! test -n "$2"; then + echo "'part' is not given" >&2 + help + exit 1 +fi part="$2" inputfile="$PWD/inputs/${day}.txt" - if ! test -f "$inputfile"; then - echo "no input available" >&2 + echo "no input available at '$inputfile'" >&2 exit 1 fi + +echo "Running benchmarks for day $day part $part" for dir in *; do if test -d "$dir"; then cd "$dir"