LinuxCommandLibrary

gleam

Run Erlang-based concurrent programs

TLDR

Create a new gleam project

$ gleam new [project_name]
copy

Build and run a gleam project
$ gleam run
copy

Build the project
$ gleam build
copy

Run a project for a particular platform and runtime
$ gleam run --target [platform] --runtime [runtime]
copy

Add a hex dependency to your project
$ gleam add [dependency_name]
copy

Run project tests
$ gleam test
copy

Format source code
$ gleam format
copy

Type check the project
$ gleam check
copy

SYNOPSIS

gleam <subcommand> [options] [arguments]
gleam --version
gleam help [<subcommand>]

PARAMETERS

new <name>
    Creates a new Gleam project with a default structure.

build
    Compiles the current Gleam project into executable artifacts.

run
    Executes the main entry point of the compiled Gleam project.

test
    Runs all unit and integration tests defined in the project.

format
    Automatically reformats Gleam source code according to official guidelines.

add <package>
    Adds a new dependency to the project's configuration file.

remove <package>
    Removes an existing dependency from the project.

deps
    Manages project dependencies, with subcommands like download, clean, and list.

shell
    Starts an interactive Gleam shell (REPL) for experimentation.

clean
    Removes compiled artifacts, build outputs, and downloaded dependencies.

docs
    Generates HTML documentation for the project's public API.

update
    Updates project dependencies to their latest compatible versions.

publish
    Publishes the current project as a package to a package registry.

--version
    Displays the installed Gleam CLI version.

help [subcommand]
    Shows help message for the CLI or a specific subcommand.

DESCRIPTION

The gleam command-line interface (CLI) is the primary tool for developing applications using the Gleam programming language. It serves as a comprehensive build tool, package manager, and development utility. Developers use it to create new projects, compile source code, run tests, format code, manage dependencies, and interact with the Gleam ecosystem. Built to streamline the development workflow, gleam integrates seamlessly with Erlang's BEAM virtual machine and can also compile to JavaScript, offering versatility for various application types, from web services to frontend applications. It abstracts away many complexities of project setup and dependency management, allowing developers to focus on writing application logic in a type-safe and concurrent environment. Its subcommands provide fine-grained control over the development lifecycle, making it an indispensable part of the Gleam development experience.

CAVEATS

The gleam command is specific to the Gleam programming language ecosystem. It is not a general-purpose Linux utility but rather a language-specific build tool. Its functionality is entirely dependent on having the Gleam compiler and runtime installed and configured correctly. It requires a Gleam project structure to operate effectively on project-specific tasks.

INSTALLATION

Gleam CLI is typically installed via a language version manager like `asdf`, a system package manager like `Homebrew` on macOS, or by downloading pre-compiled binaries from the official Gleam website. It is generally not pre-installed on standard Linux distributions.

PROJECT STRUCTURE

Gleam projects generally follow a standard directory structure. Key components include a `src/` directory for source code, a `test/` directory for tests, and a `gleam.toml` file for project configuration and dependency management.

HISTORY

The gleam command-line tool is an integral part of the Gleam programming language, which was created by Louis Pilfold and first publicly released in 2019. Developed from the outset to be a developer-friendly experience, the gleam CLI was designed to provide a unified interface for all common development tasks. Its design principles emphasize ease of use, clear error messages, and a smooth workflow, contributing significantly to Gleam's growing adoption in the functional programming community, particularly for building robust, scalable applications on the Erlang BEAM virtual machine.

SEE ALSO

mix(1), rebar3(1), cargo(1), npm(1), go(1)

Copied to clipboard