1
1
#! /usr/bin/env bash
2
2
3
-
4
3
# 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
11
10
12
11
source ./bin/generator-utils/utils.sh
13
12
source ./bin/generator-utils/prompts.sh
@@ -38,12 +37,19 @@ command -v curl >/dev/null 2>&1 || {
38
37
exit 1
39
38
}
40
39
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
+
41
48
# Check if exercise exists in configlet info or in config.json
42
49
check_exercise_existence " $1 "
43
50
44
51
# ==================================================
45
52
46
-
47
53
slug=" $1 "
48
54
# Fetch canonical data
49
55
canonical_json=$( bin/fetch_canonical_data " $slug " )
59
65
message " success" " Fetched canonical data successfully!"
60
66
fi
61
67
62
-
63
68
underscored_slug=$( dash_to_underscore " $slug " )
64
69
exercise_dir=" exercises/practice/${slug} "
65
70
exercise_name=$( format_exercise_name " $slug " )
@@ -87,7 +92,6 @@ uuid=$(bin/configlet uuid)
87
92
88
93
# Add exercise-data to global config.json
89
94
jq --arg slug " $slug " --arg uuid " $uuid " --arg name " $exercise_name " --arg difficulty " $exercise_difficulty " \
90
-
91
95
' .exercises.practice += [{slug: $slug, name: $name, uuid: $uuid, practices: [], prerequisites: [], difficulty: $difficulty}]' \
92
96
config.json > config.json.tmp
93
97
# 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."
110
114
111
115
sed -i " s/name = \" .*\" /name = \" $underscored_slug \" /" " $exercise_dir " /Cargo.toml
112
116
113
-
114
117
message " done" " All stub files were created."
115
118
116
119
message " info" " After implementing the solution, tests and configuration, please run:"
117
120
118
121
echo " ./bin/configlet fmt --update --yes --exercise ${slug} "
119
-
0 commit comments