JustBash.Commands.Command behaviour (JustBash v0.4.0)
View SourceBehaviour for bash commands.
Each command module implements this behaviour, providing a consistent interface for command execution.
Summary
Callbacks
Execute the command with the given arguments and stdin.
Returns the command name(s) this module handles.
Functions
Create a failed result with stderr output.
Create a successful result with stdout output.
Resolve a path relative to the current working directory.
Create a result with custom stdout, stderr, and exit code.
Types
Callbacks
@callback execute(bash(), args :: [String.t()], stdin :: String.t()) :: execution_result()
Execute the command with the given arguments and stdin.
The returned result map must carry :stdout, :stderr, and :exit_code, but may
contain extra keys. The executor preserves them past result validation, dropping only
internal control-flow signals before the result reaches the shell. This is load-bearing:
JustBash.CLI smuggles its resolved subcommand path through under :__subcommand__ so
command telemetry can attribute it (the executor pops it into span metadata). Do not
tighten the result match to reject unknown keys.
@callback names() :: [String.t()]
Returns the command name(s) this module handles.
Functions
@spec error(String.t(), non_neg_integer()) :: result()
Create a failed result with stderr output.
Create a successful result with stdout output.
@spec resolve_path(bash(), String.t()) :: JustBash.FS.resolved()
Resolve a path relative to the current working directory.
@spec result(String.t(), String.t(), non_neg_integer()) :: result()
Create a result with custom stdout, stderr, and exit code.