11#! /usr/bin/env bash
22
3-
43# see comment in generator-utils/utils.sh
5- # shellcheck source=bin/generator-utils/utils.sh
6- # shellcheck source=bin/generator-utils/templates.sh
7- # shellcheck source=bin/generator-utils/prompts.sh
8- # shellcheck source=./generator-utils/utils.sh
9- # shellcheck source=./generator-utils/prompts.sh
10- # shellcheck source=./generator-utils/templates.sh
4+ # shellcheck source=bin/generator-utils/utils.sh
5+ # shellcheck source=bin/generator-utils/templates.sh
6+ # shellcheck source=bin/generator-utils/prompts.sh
7+ # shellcheck source=./generator-utils/utils.sh
8+ # shellcheck source=./generator-utils/prompts.sh
9+ # shellcheck source=./generator-utils/templates.sh
1110
1211source ./bin/generator-utils/utils.sh
1312source ./bin/generator-utils/prompts.sh
@@ -38,12 +37,19 @@ command -v curl >/dev/null 2>&1 || {
3837 exit 1
3938}
4039
40+ if [ -e bin/configlet ]; then
41+ message " success" " Configlet found!"
42+ else
43+ message " info" " Fetching configlet"
44+ bin/fetch-configlet
45+ message " success" " Fetched configlet successfully!"
46+ fi
47+
4148# Check if exercise exists in configlet info or in config.json
4249check_exercise_existence " $1 "
4350
4451# ==================================================
4552
46-
4753slug=" $1 "
4854# Fetch canonical data
4955canonical_json=$( bin/fetch_canonical_data " $slug " )
5965 message " success" " Fetched canonical data successfully!"
6066fi
6167
62-
6368underscored_slug=$( dash_to_underscore " $slug " )
6469exercise_dir=" exercises/practice/${slug} "
6570exercise_name=$( format_exercise_name " $slug " )
@@ -87,7 +92,6 @@ uuid=$(bin/configlet uuid)
8792
8893# Add exercise-data to global config.json
8994jq --arg slug " $slug " --arg uuid " $uuid " --arg name " $exercise_name " --arg difficulty " $exercise_difficulty " \
90-
9195 ' .exercises.practice += [{slug: $slug, name: $name, uuid: $uuid, practices: [], prerequisites: [], difficulty: $difficulty}]' \
9296 config.json > config.json.tmp
9397# jq always rounds whole numbers, but average_run_time needs to be a float
@@ -110,10 +114,8 @@ message "success" "You've been added as the author of this exercise."
110114
111115sed -i " s/name = \" .*\" /name = \" $underscored_slug \" /" " $exercise_dir " /Cargo.toml
112116
113-
114117message " done" " All stub files were created."
115118
116119message " info" " After implementing the solution, tests and configuration, please run:"
117120
118121echo " ./bin/configlet fmt --update --yes --exercise ${slug} "
119-
0 commit comments