Batamanta.RunScript (batamanta v1.6.1)

Copy Markdown View Source

Generates the <app>.run shell script embedded in the release tarball.

The .run script is the entry point for the final binary (after the Rust wrapper extracts the payload). It sets up the environment (PATH, BINDIR, neutralizes asdf/mise) and execs the appropriate target:

  • escript format: execs release/bin/<app> directly. The escript shebang (#!/usr/bin/env escript) finds the bundled escript via PATH, which finds erl via PATH, which finds erlexec via BINDIR. No ESCRIPT_EMULATOR needed on OTP ≤ 26.

  • release format: execs release/bin/<app> with the right subcommand:

    • clieval 'Module.CLI.main()' -- "$@"
    • daemondaemon "$@"
    • tuistart "$@"

This script is ~1KB and is GENERATED at build time by batamanta, not at runtime by the Rust wrapper. Changing env vars does NOT require recompiling the Rust dispenser.

Summary

Functions

Derives the CLI module name from the application name.

Generates the .run script content as a string.

Functions

derive_cli_module(app_name)

@spec derive_cli_module(String.t()) :: String.t()

Derives the CLI module name from the application name.

Examples

iex> Batamanta.RunScript.derive_cli_module("delfos")
"Delfos.CLI"

iex> Batamanta.RunScript.derive_cli_module("test_escript")
"TestEscript.CLI"

generate(app_name, exec_mode, format, erts_version, opts \\ [])

@spec generate(String.t(), atom(), atom(), String.t(), keyword()) :: String.t()

Generates the .run script content as a string.

Parameters

  • app_name - Application name (e.g., "delfos", "test_escript")
  • exec_mode - Execution mode: :cli, :daemon, or :tui
  • format - Output format: :escript or :release
  • erts_version - ERTS version string (e.g., "14.2")
  • opts - Optional overrides:
    • :cli_module - Custom CLI module (default: Macro.camelize(app_name) <> ".CLI")

Returns

String containing the run script (with trailing newline).