Trebejo.SafeCommand (Trebejo v2.0.0)

Copy Markdown View Source

Safe wrapper around Arrea.Command.execute/2.

This is the single entry point for all command execution in Trebejo. Modules must call SafeCommand.execute/3 instead of calling Arrea.Command.execute/2 directly.

Validation ensures:

  • the command name is non‑empty and contains only safe characters
  • each argument passes the shell_quote/1 transform

Usage

# Run a simple command:
SafeCommand.execute("echo", ["hello"], validate: false)

Summary

Functions

Executes a command string directly (legacy API).

Executes a command with the given arguments.

Functions

execute(cmd_str)

@spec execute(binary()) :: {:ok, map()} | {:error, term()}

Executes a command string directly (legacy API).

Validates the command and delegates to Arrea.Command.execute/2. For new code, prefer execute/3 with explicit arg lists.

execute(cmd_name, args, opts \\ [])

@spec execute(binary(), [binary()], keyword()) :: {:ok, map()} | {:error, term()}

Executes a command with the given arguments.

Options