Allow passing in author to add-exercise script (#146)

This commit is contained in:
Erik Schierboom
2024-04-25 02:58:33 +02:00
committed by GitHub
parent ec41592664
commit c9907a16dd

View File

@@ -2,9 +2,9 @@
set -euo pipefail
if (( $# != 1 )); then
if (( $# < 1 )); then
echo >&2 "Populates a new directory for a practice exercise."
echo >&2 "Usage: $0 <exercise-slug>"
echo >&2 "Usage: $0 <exercise-slug> [author]"
exit 1
fi
@@ -39,8 +39,13 @@ end-of-tests
;with
END_TEST
echo
read -rp 'Your github username: ' author
if (( $# < 2 )); then
echo
read -rp 'Your github username: ' author
else
author="${2}"
fi
conf="exercises/practice/${slug}/.meta/config.json"
jq --arg author "${author}" \
'.authors = [$author]' "${conf}" > "${conf}.tmp" \