Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bin/create-exercise #275

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions bin/create-exercise
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -e

die() { echo "$*" >&2; exit 1; }

if [[ $PWD != $(realpath "$(dirname "$0")/..") ]]; then
die "You must be in the track root directory."
fi
if [[ -z $1 ]]; then
die "usage: $0 exercise_slug"
fi

slug=$1

existing=$( jq --arg slug "${slug}" '.exercises.practice[] | select(.slug == $slug)' config.json )
if [[ -n ${existing} ]]; then
die "${slug} already exists in config.json"
fi

if [[ -z $author ]]; then
echo
read -rp "What's your github username? " author
fi

read -p "What's the difficulty for ${slug}? " difficulty

bin/fetch-configlet
bin/configlet create --practice-exercise "${slug}" --author "${author}" --difficulty "${difficulty}"

cp exercises/practice/hello-world/.docs/hints.md exercises/practice/${slug}/.docs/hints.md

touch exercises/practice/${slug}/.docs/instructions.append.md
74 changes: 30 additions & 44 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@
"runner.mips"
],
"example": [
"example.mips"
".meta/example.mips"
],
"exemplar": [
".meta/exemplar.mips"
]
},
"exercises": {
"concept": [],
"practice": [
{
"slug": "hello-world",
Expand All @@ -53,19 +52,18 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"status": "deprecated",
"topics": [
"math"
],
"status": "deprecated"
]
},
{
"slug": "leap",
"name": "Leap",
"uuid": "d3026f71-47d0-44d1-92ac-204404d4e26e",
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": []
"difficulty": 1
},
{
"slug": "difference-of-squares",
Expand Down Expand Up @@ -111,8 +109,7 @@
"uuid": "2ba35b0f-e16c-41be-81b4-88985926445a",
"practices": [],
"prerequisites": [],
"difficulty": 3,
"topics": []
"difficulty": 3
},
{
"slug": "grains",
Expand All @@ -136,8 +133,7 @@
"uuid": "50cacd4d-56c2-4331-b84f-7c91e4b12c35",
"practices": [],
"prerequisites": [],
"difficulty": 2,
"topics": []
"difficulty": 2
},
{
"slug": "eliuds-eggs",
Expand Down Expand Up @@ -177,17 +173,15 @@
"uuid": "823ca6fc-369c-468c-914e-b53bb0db4763",
"practices": [],
"prerequisites": [],
"difficulty": 4,
"topics": []
"difficulty": 4
},
{
"slug": "binary-search",
"name": "Binary Search",
"uuid": "25145170-d7d4-4f72-8a4f-a44b6f3880da",
"practices": [],
"prerequisites": [],
"difficulty": 4,
"topics": []
"difficulty": 4
},
{
"slug": "prime-factors",
Expand All @@ -214,26 +208,23 @@
"uuid": "fa283d1e-2005-40d3-9a30-252d06d98523",
"practices": [],
"prerequisites": [],
"difficulty": 4,
"topics": []
"difficulty": 4
},
{
"slug": "scrabble-score",
"name": "Scrabble Score",
"uuid": "42c7d965-c56c-437f-b513-19bcbcedef01",
"practices": [],
"prerequisites": [],
"difficulty": 5,
"topics": []
"difficulty": 5
},
{
"slug": "raindrops",
"name": "Raindrops",
"uuid": "d294d722-8ea2-461e-86d8-0fecb6c5637a",
"practices": [],
"prerequisites": [],
"difficulty": 5,
"topics": []
"difficulty": 5
},
{
"slug": "spiral-matrix",
Expand Down Expand Up @@ -269,10 +260,10 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"status": "deprecated",
"topics": [
"math"
],
"status": "deprecated"
]
},
{
"slug": "octal",
Expand All @@ -281,10 +272,10 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"status": "deprecated",
"topics": [
"math"
],
"status": "deprecated"
]
},
{
"slug": "bob",
Expand Down Expand Up @@ -328,10 +319,10 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"status": "deprecated",
"topics": [
"math"
],
"status": "deprecated"
]
},
{
"slug": "two-fer",
Expand Down Expand Up @@ -416,8 +407,7 @@
"uuid": "429467c7-edf4-4010-a696-5fc76d0dd12c",
"practices": [],
"prerequisites": [],
"difficulty": 3,
"topics": []
"difficulty": 3
},
{
"slug": "pangram",
Expand Down Expand Up @@ -452,26 +442,23 @@
"uuid": "e7a3845a-2f5a-455a-9158-0a7d1c1d5979",
"practices": [],
"prerequisites": [],
"difficulty": 3,
"topics": []
"difficulty": 3
},
{
"slug": "kindergarten-garden",
"name": "Kindergarten Garden",
"uuid": "bc580dd5-6a6b-48ce-84b3-6f60b9da2db2",
"practices": [],
"prerequisites": [],
"difficulty": 4,
"topics": []
"difficulty": 4
},
{
"slug": "phone-number",
"name": "Phone Number",
"uuid": "60bcccb4-589f-4465-a7d8-c84b22494306",
"practices": [],
"prerequisites": [],
"difficulty": 4,
"topics": []
"difficulty": 4
},
{
"slug": "matching-brackets",
Expand Down Expand Up @@ -553,13 +540,12 @@
"prerequisites": [],
"difficulty": 8
}
],
"foregone": [
"bank-account",
"parallel-letter-frequency"
]
},
"foregone": [
"bank-account",
"parallel-letter-frequency"
],
"concepts": [],
"key_features": [
{
"title": "Easy to Learn",
Expand Down Expand Up @@ -593,15 +579,15 @@
}
],
"tags": [
"execution_mode/compiled",
"paradigm/imperative",
"paradigm/procedural",
"typing/static",
"typing/weak",
"execution_mode/compiled",
"platform/windows",
"platform/mac",
"platform/linux",
"platform/mac",
"platform/windows",
"runtime/standalone_executable",
"typing/static",
"typing/weak",
"used_for/embedded_systems"
]
}