Skip to content

Slangroom double sided executor

Notifications You must be signed in to change notification settings

ForkbombEu/gemini

Repository files navigation

Gemini

Gemini is a command-line interface (CLI) tool that enables you to execute slangroom contracts written in Zencode language.

Contracts can be both embedded within the tool (compiled at build time) and added dynamically from specified folders (specified at runtime).

It also provides an easy way to list and run currently configured contracts both as CLI commands or as HTTP API endpoints served in daemon mode.

When dynamic run-time contract files have the same path as built-in embedded contracts, then the contracts placed in the contracts folder at build time have priority and will override the rest.

Installation

To use Gemini, you need Go installed on your system. If you don't have Go installed, you can download it from golang.org.

Clone the repository:

git clone https://github.com/ForkbombEu/gemini

Build the executable:

You can build the executable using either the go build command or the provided Makefile. Using go build:

To build the binary with a custom name using go build, run:

go build -o <custom_name> .

Using make build:

make build BINARY_NAME=<custom_name>

If you want to specify a custom binary name, you can do so by passing the BINARY_NAME variable.

Replace <custom_name> with your desired binary name.

Usage

List Command

To list all slangroom files in a specified directory, use the following command:

./out/bin/gemini list <folder>

If you want to list only embedded files in the contracts folder, simply run:

./out/bin/gemini list

Run a file

To execute a specific slangroom file, use the following command:

out/bin/./gemini <folder> <file>

If the file is embedded in the contracts folder , you can also run it directly by providing just the filename:

out/bin/./gemini  <file>

Or if it is in a subdir of contracts:

out/bin/./gemini  <subdir> <file>

Daemon Mode

Gemini can also run in daemon mode, exposing the slangroom files via an HTTP server. Use the -d or --daemon flag:

./out/bin/gemini -d <folder> <file>

If a folder is provided with the -d flag and the list command, Gemini will list the available slangroom files via HTTP.

./out/bin/gemini list  -d <folder>

Adding Additional Data to Slangroom Contrats

Gemini supports loading additional JSON-based data for each slangroom file. This data can be provided through optional JSON files with specific names, stored alongside the main slangroom file in the same directory. The parameters can be:

  • data
  • keys
  • extra
  • context
  • conf

To add data for a specific slangroom file, create JSON files following the naming convention below:

<filename>.<param>.json

Where:

  • <filename> is the name of your contract file.
  • <param> is one of the parameters listed above.

For example, if you have a file called hello.slang, you can provide additional data by creating files like:

hello.data.json
hello.keys.json
hello.extra.json

Command Arguments and Flags from metadata.json

In addition to the above parameters, Gemini allows you to define custom arguments and flags for each embedded slangroom file using a metadata.json file. This file provides information on how to pass data to the contract through the CLI, including:

  • Arguments: Custom positional arguments for the command.
  • Options: Custom flags that can be passed to the command.

Structure of metadata.json

The metadata file is automatically read by Gemini to generate appropriate arguments and flags when executing embedded contract files. A typical metadata.json structure might look like this:

{
    "description": "Example of a command with different arguments and options",
    "arguments": [
        {
            "name": "<username>",
            "description": "user to login"
        },
        {
            "name": "[password]",
            "description": "password for user if required"
        }
    ],
    "options": [
        {
            "name": "-n, --name <name>"
        },
        {
            "name": "-s, --secret",
            "hidden": true
        },
        {
            "name": "-t, --timeout <delay>",
            "description": "timeout in seconds",
            "default": "60"
        },
        {
            "name": "-p, --port <number>",
            "description": "port number",
            "env": [
                "PORT"
            ]
        },
        {
            "name": "-D, --drink <size>",
            "description": "drink size",
            "choices": [
                "small",
                "medium",
                "large"
            ]
        }

    ]
}

The parameters passed from CLI will overwrite the same parameter if contained in filename.metadata.json

Examples

List all contracts in the examples folder:

./out/bin/gemini list examples

Run a specific contract:

./out/bin/gemini examples hello

Run a contract with arguments and flag:

out/bin/gemini test param username -n myname -D small -t 100

Start the HTTP server to expose contract:

./out/bin/gemini -d examples hello

📝 Site docs

go install golang.org/x/pkgsite/cmd/pkgsite@latest && pkgsite

About

Slangroom double sided executor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •