Current section
Files
Jump to
Current section
Files
lib/command_result.ex
defmodule Argos.CommandResult do
@moduledoc """
Estructura de resultado para `Argos.exec/*`.
Contiene comando, argumentos, salida estándar combinada, `exit_code`,
duración en milisegundos, bandera de éxito y posible error.
"""
@type t :: %__MODULE__{
command: String.t(),
args: [String.t()],
output: String.t(),
exit_code: non_neg_integer(),
duration: non_neg_integer(),
success?: boolean(),
error: String.t() | nil
}
defstruct [
:command,
:args,
:output,
:exit_code,
:duration,
:success?,
:error
]
@doc """
Crea un CommandResult exitoso.
"""
@spec success(String.t(), [String.t()], String.t(), non_neg_integer) :: t()
def success(command, args, output, duration) do
%__MODULE__{
command: command,
args: args,
output: output,
exit_code: 0,
duration: duration,
success?: true,
error: nil
}
end
@doc """
Crea un CommandResult fallido.
"""
@spec failure(String.t(), [String.t()], String.t(), non_neg_integer, non_neg_integer, String.t()) :: t()
def failure(command, args, output, exit_code, duration, error) do
%__MODULE__{
command: command,
args: args,
output: output,
exit_code: exit_code,
duration: duration,
success?: false,
error: error
}
end
end