Skip to content
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
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,31 @@

This project provides a command-line interface to [Source++](https://github.com/sourceplusplus/live-platform), the open-source live coding platform.

# Install

## Quick install

### Linux or macOS

Install the latest version with the following command:

```shell
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/sourceplusplus/interface-cli/master/scripts/install.sh)"
```

### Windows

Note: you need to start cmd or PowerShell in administrator mode.

```shell
curl -LO "https://raw.githubusercontent.com/sourceplusplus/interface-cli/master/scripts/install.bat" && .\install.bat
```

## Install by available binaries

Go to the [releases page](https://github.com/sourceplusplus/interface-cli/releases) to download all available binaries,
including macOS, Linux, Windows.

# Usage

Try executing `spp-cli --help` to output the usage instructions like so:
Expand Down
32 changes: 32 additions & 0 deletions scripts/install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@REM Installation (Note: you need to start cmd or powershell in administrator mode.)
@echo off
setlocal ENABLEDELAYEDEXPANSION

@REM Get the latest version of spp-cli.
set FLAG="FALSE"
set VERSION= UNKNOWN
curl -s https://api.github.com/repos/sourceplusplus/interface-cli/releases/latest > response.txt
FOR /F "tokens=*" %%g IN ('FIND "tag_name" "response.txt"') do set result=%%g
set "tag_name=%result:"tag_name": "=%"
set "VERSION=%tag_name:",=%"
@echo The latest version of spp-cli is %VERSION%

@REM Download the binary package.
curl -LO "https://github.com/sourceplusplus/interface-cli/releases/download/%VERSION%/spp-cli-%VERSION%-win64.zip"
if EXIST "spp-cli-%VERSION%-win64.zip" (
tar -xf ".\spp-cli-%VERSION%-win64.zip"

mkdir "C:\Program Files\spp-cli"

@REM Add spp-cli to the environment variable PATH.
copy ".\spp-cli.exe" "C:\Program Files\spp-cli\spp-cli.exe"
setx "Path" "C:\Program Files\spp-cli\;%path%" /m

@REM Delete unnecessary files.
del ".\response.txt"
del ".\spp-cli-%VERSION%-win64.zip"

@echo Reopen the terminal and type 'spp-cli --help' to get more information.
) else (
@echo Failed to download spp-cli-%VERSION%-win64.zip
)
59 changes: 59 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# Treat unset variables and parameters other than the special parameters ‘@’ or ‘*’ as an error.
set -u

# Exit the script with a message.
abort() {
printf "%s\n" "$@"
exit 1
}

# Check if there is a bash.
if [ -z "${BASH_VERSION:-}" ]; then
abort "Bash is required to interpret this install script."
fi

# Check OS.
OS="$(uname)"
if [[ "$OS" != "Darwin" && "$OS" != "Linux" ]]; then
abort "The install script is only supported on macOS and Linux."
fi

check_cmd() {
if ! command -v "$@" &> /dev/null
then
abort "You must install "$@" before running the install script."
fi
}

# Check if the commands to be used exist.
for cmd in curl unzip; do
check_cmd $cmd
done

get_latest_release_number() {
curl --silent "https://github.com/sourceplusplus/interface-cli/releases/latest" | sed 's#.*tag/\(.*\)\".*#\1#'
}

# Get the latest version of spp-cli.
VERSION=$(get_latest_release_number)
echo "Installing spp-cli $VERSION"

# Download the binary package.
curl -sSLO "https://github.com/sourceplusplus/interface-cli/releases/download/$VERSION/spp-cli-$VERSION-linux64.zip" > /dev/null
if [ -f "spp-cli-$VERSION-linux64.zip" ]; then
unzip -q spp-cli-$VERSION-linux64.zip

echo "Adding spp-cli to your PATH"
# Add spp-cli to the environment variable PATH.
sudo mv spp-cli /usr/local/bin/spp-cli

# Delete unnecessary files.
rm "./spp-cli-$VERSION-linux64.zip"
echo "Installation complete."

echo "Type 'spp-cli --help' to get more information."
else
abort "Failed to download spp-cli-$VERSION-linux64.zip"
fi