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
37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ Fast and convenient CLI utility for working with the [Jelly](https://jelly-rdf.g

## Quick start

If you are using Linux (x86_64, ARM64), macOS (ARM64), or Windows (x86_64), the recommended way run `jelly-cli` is to use a pre-built binary. Go to the **[releases page](https://github.com/Jelly-RDF/cli/releases/latest)** and download the binary built for your platform.
If you are using Linux (x86_64, ARM64), macOS (ARM64), or WSL on Windows, the recommended way is to use the `install.sh` script, which will automatically install the newest release.
To do so, run:

```shell
$ . <(curl -sSfL https://raw.githubusercontent.com/Jelly-RDF/cli/main/install.sh)
$ jelly-cli
```


For Windows (x86_64), the recommended way run `jelly-cli` is to use a pre-built binary. Go to the **[releases page](https://github.com/Jelly-RDF/cli/releases/latest)** and download the binary built for your platform.

You can then run it like so:

```shell
$ chmod +x jelly-cli
$ ./jelly-cli --help
$ ./jelly-cli
```

## Usage
Expand All @@ -22,22 +31,22 @@ $ ./jelly-cli --help
To convert an RDF file (e.g., Turtle) to Jelly, simply run:

```shell
$ ./jelly-cli rdf to-jelly input.ttl > output.jelly
$ jelly-cli rdf to-jelly input.ttl > output.jelly
```

### Convert Jelly to RDF

To convert from Jelly to RDF run:

```shell
$ ./jelly-cli rdf from-jelly input.jelly > output.nq
$ jelly-cli rdf from-jelly input.jelly > output.nq
```

By default, `jelly-cli` will translate files to NQuads.
But you can also specify the output format with `--out-format`, for example:

```shell
$ ./jelly-cli rdf from-jelly input.jelly --out-format=ttl > output.ttl
$ jelly-cli rdf from-jelly input.jelly --out-format=ttl > output.ttl
```

You can specify most well-known formats supported by Apache Jena, but also a custom Jelly-Text format.
Expand All @@ -48,21 +57,21 @@ Jelly-Text is a human-readable translation of Jelly binary. It's not meant for m
The `rdf transcode` command turns one or more input Jelly streams into a single output stream. It's extremely fast, using a dedicated transcoding algorithm. However, the numerical values for each of the options in the output stream must be greater than or equal to those in the input stream(s).

```shell
$ ./jelly-cli rdf transcode input.jelly > output.jelly
$ jelly-cli rdf transcode input.jelly > output.jelly
```

### Inspect Jelly files

To inspect a Jelly file and get basic information describing its contents, such as stream options or number of triples in the file, run

```shell
$ ./jelly-cli rdf inspect input.jelly
$ jelly-cli rdf inspect input.jelly
```

You can also compute the statistics separately for each stream frame with the `--per-frame` option:

```shell
$ ./jelly-cli rdf inspect input.jelly --per-frame
$ jelly-cli rdf inspect input.jelly --per-frame
```

In both cases, you will get the output as a valid YAML.
Expand All @@ -72,7 +81,7 @@ In both cases, you will get the output as a valid YAML.
To validate a Jelly file, run

```shell
$ ./jelly-cli rdf validate input.jelly
$ jelly-cli rdf validate input.jelly
```

You can also check whether the Jelly file has been encoded using specific stream options or is equivalent to another RDF file, with the use of additional options to this command.
Expand All @@ -82,11 +91,11 @@ You can also check whether the Jelly file has been encoded using specific stream
Use the `--help` option to learn more about all the available settings:

```shell
$ ./jelly-cli rdf to-jelly --help
$ ./jelly-cli rdf from-jelly --help
$ ./jelly-cli rdf transcode --help
$ ./jelly-cli rdf inspect --help
$ ./jelly-cli rdf validate --help
$ jelly-cli rdf to-jelly --help
$ jelly-cli rdf from-jelly --help
$ jelly-cli rdf transcode --help
$ jelly-cli rdf inspect --help
$ jelly-cli rdf validate --help
```

And use the `--debug` option to get more information about any exceptions you encounter.
Expand Down
93 changes: 93 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash

# This script installs the latest cli release from the GitHub repository
# Let's start by fetching the latest release information
REPO_BASE="Jelly-RDF/cli"
REPO="https://api.github.com/repos/$REPO_BASE/releases/latest"
RELEASE_INFO=$(curl -s $REPO)

# And let's get the tag name of the latest release
TAG_NAME=$(echo $RELEASE_INFO | grep -o '"tag_name": "[^"]*' | sed 's/"tag_name": "//')
if [ -z "$TAG_NAME" ]; then
echo "Error: Could not fetch the latest release tag name."
return 1
exit 1
fi

# Check the operating system and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
# Map the architecture to the appropriate binary name
case $OS in
linux) BINARY_NAME="jelly-cli-linux" ;;
darwin) BINARY_NAME="jelly-cli-mac" ;;
*) echo "Unsupported operating system: $OS"; exit 1 ;;
esac
# Append the architecture to the binary name but yell for cases we don't support
case $ARCH in
x86_64) ARCH_NAME="-x86_64"
# check that os not darwin here
if [ "$OS" = "darwin" ]; then
echo "Unsupported architecture: $ARCH on macOS"
return 1
exit 1
fi;;
aarch64)
ARCH_NAME="-arm64" ;;
arm64)
ARCH_NAME="-arm64" ;;
*) echo "Unsupported architecture: $ARCH"
return 1
exit 1
;;
esac

# Check the installation directory
INSTALL_DIR="$HOME/.local/bin"
if [ ! -d "$INSTALL_DIR" ]; then
echo "Creating installation directory: $INSTALL_DIR"
mkdir -p "$INSTALL_DIR"
fi


# Download the binary
DOWNLOAD_URL="https://github.com/$REPO_BASE/releases/download/$TAG_NAME/$BINARY_NAME$ARCH_NAME"
echo "Downloading $BINARY_NAME from $DOWNLOAD_URL"
curl -L "$DOWNLOAD_URL" -o "$INSTALL_DIR/jelly-cli"
CONTENT=$(wc -c "$INSTALL_DIR/jelly-cli" | awk '{print $1}')
if [ $CONTENT -lt 500 ]; then
echo "Error: Failed to download the binary from $DOWNLOAD_URL"
return 1
exit 1
fi
chmod +x "$INSTALL_DIR/jelly-cli"

# Ensure that the installation directory is in the PATH
if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then
echo "Adding $INSTALL_DIR to PATH"
# Add the binary to the PATH for the current session
export PATH="$PATH:$INSTALL_DIR"
# Check shell config file from bash and zsh
if expr "$SHELL" : '.*zsh' >/dev/null; then
echo "export PATH=\"\$PATH:$INSTALL_DIR\"" >> "$HOME/.zshrc"
elif expr "$SHELL" : '.*bash' >/dev/null; then
echo "export PATH=\"\$PATH:$INSTALL_DIR\"" >> "$HOME/.bashrc"
fi
fi

# Link the binary to the installation directory
if [ -f "$INSTALL_DIR/jelly-cli" ]; then
echo "Installation successful! You can now use Jelly CLI by running 'jelly-cli'."
else
echo "Error: Installation failed. The binary was not found in the installation directory."
exit 1
fi

# Check if zsh or bash is being used and source the appropriate file
if expr "$SHELL" : '.*zsh' >/dev/null; then
echo "Run source ""$HOME/.zshrc"" or restart your terminal to permanently link the jelly-cli command."
elif expr "$SHELL" : '.*bash' >/dev/null; then
echo "Run source ""$HOME/.bashrc"" or restart your terminal to permanently link the jelly-cli command."
fi