Skip to content

Commit 697467a

Browse files
authored
install: Make elixir and otp versions required (#1779)
1 parent e0c8e33 commit 697467a

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

Diff for: install.bat

+19-11
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,17 @@ REM https://github.com/elixir-lang/elixir-lang.github.com/blob/main/install.bat
44

55
setlocal EnableDelayedExpansion
66

7-
set "otp_version=latest"
8-
set "elixir_version=latest"
7+
set "otp_version="
8+
set "elixir_version="
99
set "force=false"
1010

1111
goto :main
1212

1313
:usage
14-
echo Usage: install.bat [arguments] [options]
14+
echo Usage: install.bat elixir@ELIXIR_VERSION otp@OTP_VERSION [options]
1515
echo.
16-
echo Arguments:
17-
echo.
18-
echo elixir@VERSION Install specific Elixir version. The version can be X.Y.Z, latest, or main
19-
echo otp@VERSION Install specific Erlang/OTP version. The version can be X.Y.Z or latest
20-
echo.
21-
echo By default, elixir@latest and otp@latest are installed.
16+
echo ELIXIR_VERSION can be X.Y.Z, latest, or main.
17+
echo OTP_VERSION can be X.Y.Z or latest.
2218
echo.
2319
echo Options:
2420
echo.
@@ -27,9 +23,9 @@ echo -h, --help Prints this help
2723
echo.
2824
echo Examples:
2925
echo.
30-
echo install.bat
3126
32-
echo install.bat elixir@main
27+
echo install.bat elixir@latest otp@latest
28+
echo install.bat elixir@main otp@latest
3329
echo.
3430
goto :eof
3531

@@ -57,6 +53,18 @@ for %%i in (%*) do (
5753
)
5854
)
5955

56+
if "%elixir_version%" == "" (
57+
call :usage
58+
echo error: missing elixir@VERSION argument
59+
exit /b 1
60+
)
61+
62+
if "%otp_version%" == "" (
63+
call :usage
64+
echo error: missing otp@VERSION argument
65+
exit /b 1
66+
)
67+
6068
if "!otp_version!" == "latest" (
6169
set "url=https://github.com/erlef/otp_builds/releases/latest"
6270
for /f "tokens=2 delims= " %%a in ('curl -fsS --head "!url!" ^| findstr /I "^location:"') do set url=%%a

Diff for: install.sh

+19-13
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,16 @@
44

55
set -eu
66

7-
otp_version=latest
8-
elixir_version=latest
7+
otp_version=
8+
elixir_version=
99
force=false
1010

1111
usage() {
1212
cat<<EOF
13-
Usage: install.sh [arguments] [options]
13+
Usage: install.sh elixir@ELIXIR_VERSION otp@OTP_VERSION [options]
1414
15-
Arguments:
16-
17-
elixir@VERSION Install specific Elixir version. The version can be X.Y.Z, latest, or main
18-
otp@VERSION Install specific Erlang/OTP version. The version can be X.Y.Z, latest,
19-
master, maint, or maint-RELEASE (e.g. maint-27)
20-
21-
By default, elixir@latest and otp@latest are installed.
15+
ELIXIR_VERSION can be X.Y.Z, latest, or main.
16+
OTP_VERSION can be X.Y.Z, latest, master, maint, or maint-RELEASE (e.g. maint-27).
2217
2318
Options:
2419
@@ -27,13 +22,11 @@ Options:
2722
2823
Examples:
2924
30-
sh install.sh
3125
32-
sh install.sh elixir@main
26+
sh install.sh elixir@latest otp@latest
3327
sh install.sh elixir@main otp@master
3428
3529
EOF
36-
exit 0
3730
}
3831

3932
main() {
@@ -47,6 +40,7 @@ main() {
4740
;;
4841
-h|--help)
4942
usage
43+
exit 0
5044
;;
5145
-f|--force)
5246
force=true
@@ -58,6 +52,18 @@ main() {
5852
esac
5953
done
6054

55+
if [ -z "${elixir_version}" ]; then
56+
usage
57+
echo "error: missing elixir@VERSION argument"
58+
exit 1
59+
fi
60+
61+
if [ -z "${otp_version}" ]; then
62+
usage
63+
echo "error: missing otp@VERSION argument"
64+
exit 1
65+
fi
66+
6167
root_dir="$HOME/.elixir-install"
6268
tmp_dir="$root_dir/tmp"
6369
mkdir -p "$tmp_dir"

0 commit comments

Comments
 (0)