Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 023defa

Browse files
committed
fixup! Add install script and readme snippet
1 parent 39fe5f7 commit 023defa

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

install.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fi
1010

1111
if [ "$OS" = "Windows_NT" ]; then
1212
target="windows-386"
13-
ext=".zip"
13+
extension=".zip"
1414
if ! command -v unzip >/dev/null; then
1515
echo "Error: unzip is required to install coder-cli" 1>&2
1616
exit 1
@@ -20,17 +20,18 @@ else
2020
echo "Error: tar is required to install coder-cli" 1>&2
2121
exit 1
2222
fi
23-
ext=".tar.gz"
23+
extension=".tar.gz"
2424
case $(uname -s) in
2525
Darwin) target="darwin-amd64" ;;
2626
*) target="linux-amd64" ;;
2727
esac
2828
fi
2929

30-
if [ $# -eq 0 ]; then
30+
version=${1:-""}
31+
if [ "$version" == "" ]; then
3132
coder_asset_path=$(
3233
curl -sSf https://github.com/cdr/coder-cli/releases |
33-
grep -o "/cdr/coder-cli/releases/download/.*/coder-cli-${target}${ext}" |
34+
grep -o "/cdr/coder-cli/releases/download/.*/coder-cli-${target}${extension}" |
3435
head -n 1
3536
)
3637
if [ ! "$coder_asset_path" ]; then
@@ -39,7 +40,7 @@ if [ $# -eq 0 ]; then
3940
fi
4041
cdr_uri="https://github.com${coder_asset_path}"
4142
else
42-
cdr_uri="https://github.com/cdr/coder-cli/releases/download/${1}/coder-cli-${target}${ext}"
43+
cdr_uri="https://github.com/cdr/coder-cli/releases/download/${1}/coder-cli-${target}${extension}"
4344
fi
4445

4546
coder_install="${CODER_INSTALL:-$HOME/.coder}"
@@ -50,14 +51,14 @@ if [ ! -d "$bin_dir" ]; then
5051
mkdir -p "$bin_dir"
5152
fi
5253

53-
curl --fail --location --progress-bar --output "$exe$ext" "$cdr_uri"
54-
if [ "$ext" = ".zip" ]; then
55-
unzip -d "$bin_dir" -o "$exe$ext"
54+
curl --fail --location --progress-bar --output "$exe$extension" "$cdr_uri"
55+
if [ "$extension" = ".zip" ]; then
56+
unzip -d "$bin_dir" -o "$exe$extension"
5657
else
57-
tar -xzf "$exe$ext" -C "$bin_dir"
58+
tar -xzf "$exe$extension" -C "$bin_dir"
5859
fi
5960
chmod +x "$exe"
60-
rm "$exe$ext"
61+
rm "$exe$extension"
6162

6263
echo "Coder was installed successfully to $exe"
6364
if command -v coder >/dev/null; then

0 commit comments

Comments
 (0)