Skip to content

Commit 6bf0a45

Browse files
committed
Add feature: exercism-cli.
1 parent 224dccc commit 6bf0a45

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "Exercism CLI",
3+
"id": "exercism-cli",
4+
"version": "1.0.0",
5+
"description": "Install the exercism-cli.",
6+
"options": {
7+
"version": {
8+
"default": "latest",
9+
"description": "Specify what version to install.",
10+
"type": "string"
11+
},
12+
"destdir": {
13+
"default": "/usr/local/bin/",
14+
"description": "Filesystem location of the exercism binary.",
15+
"type": "string"
16+
},
17+
"os": {
18+
"default": "linux",
19+
"description": "Specify the target operating system.",
20+
"enum": [
21+
"darwin",
22+
"freebsd",
23+
"linux",
24+
"openbsd"
25+
],
26+
"type": "string"
27+
},
28+
"arch": {
29+
"default": "x86_64",
30+
"description": "Specify the target CPU architecture.",
31+
"enum": [
32+
"armv5",
33+
"armv6",
34+
"i386",
35+
"ppc64",
36+
"x86_64"
37+
],
38+
"type": "string"
39+
}
40+
}
41+
}

src/exercism-cli/install.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Install the Exercism CLI tool
4+
# https://github.com/exercism/cli
5+
#
6+
# Dependencies: curl, cut
7+
#
8+
# Environment:
9+
# - VERSION: The version to install [default: latest].
10+
# - DESTDIR: The destination of the executable [default: /usr/local/bin/].
11+
# - OS: [default: linux]
12+
# - ARCH: [default: x86_64]
13+
14+
set -e
15+
16+
GITHUB_BASE_URL="https://github.com/exercism/cli"
17+
LATEST_URL="${GITHUB_BASE_URL}/releases/latest/"
18+
DESTDIR="${DESTDIR:-/usr/local/bin}"
19+
OS="${OS:-linux}"
20+
ARCH="${ARCH:-x86_64}"
21+
22+
if [[ -z "$VERSION" ]] || [[ "$VERSION" = "latest" ]]; then {
23+
VERSION=$(curl -sLI -o /dev/null -w '%{url_effective}' "$LATEST_URL" | cut -d "v" -f 2)
24+
} fi
25+
26+
echo "Installing exercism-cli: v${VERSION}"
27+
28+
RELEASE_URL="${GITHUB_BASE_URL}/releases/download/v${VERSION}/exercism-${VERSION}-${OS}-${ARCH}.tar.gz"
29+
DOWNLOAD_DIR=$(mktemp -d || mktemp -d -t 'tmp')
30+
pushd "$DOWNLOAD_DIR"
31+
curl -sL --retry 3 "$RELEASE_URL" | tar -xz
32+
echo "Installing to $DESTDIR"
33+
install exercism "$DESTDIR"
34+
popd
35+
rm -r "$DOWNLOAD_DIR"

test/exercism-cli/test.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
7+
check "version" bash -c "exercism"
8+
9+
reportResults

0 commit comments

Comments
 (0)