Raxol.System.Interaction behaviour (Raxol v0.5.0)

View Source

Behaviour for abstracting system interactions like running commands, finding executables, and getting OS type. Allows for easier testing.

Summary

Callbacks

Finds the full path to an executable. Returns nil if not found.

Returns the OS type.

Executes a system command. Returns {output, exit_status} on success. Can raise exceptions on errors depending on the implementation. Options can be passed to control execution (e.g., stderr_to_stdout).

Types

os_type()

@type os_type() ::
  {:unix, :linux}
  | {:unix, :darwin}
  | {:win32, :nt}
  | {:unix, atom()}
  | {:win32, atom()}

Callbacks

find_executable(binary)

@callback find_executable(binary()) :: binary() | nil

Finds the full path to an executable. Returns nil if not found.

get_os_type()

@callback get_os_type() :: os_type()

Returns the OS type.

system_cmd(binary, list, list)

@callback system_cmd(binary(), [binary()], [atom() | tuple()]) :: {binary(), integer()}

Executes a system command. Returns {output, exit_status} on success. Can raise exceptions on errors depending on the implementation. Options can be passed to control execution (e.g., stderr_to_stdout).