View Source edifa_exec (edifa v1.0.0)
Summary
Types
-type call_return() :: {call, [call_spec() | command_handler()], LastResult :: term(), NewState :: term()}.
-type call_spec() :: #{cmd := atom(), args => [string() | binary()], env => [string() | binary() | clear | {Name :: string() | binary(), Val :: string() | binary() | false}], on_start => start_handler(), on_data => data_handler(), on_exit => exit_handler(), handler => command_handler(), input => undefined | command_input_data(), result => undefined | {match, iodata() | unicode:charlist()} | {match, iodata() | unicode:charlist(), re:options()} | {match, iodata() | unicode:charlist(), re:options(), fun((list()) -> term())} | {collect, stdout | stderr | both}, result_default => undefined, keep_result => undefined | atom(), error => undefined | {match, iodata() | unicode:charlist()} | {match, iodata() | unicode:charlist(), re:options()} | {match, iodata() | unicode:charlist(), re:options(), fun((list()) -> term())} | {collect, stdout | stderr | both}, error_default => undefined, error_as_result => undefined | boolean()}.
-type command_handler() :: full_command_handler() | simple_command_handler().
-type command_input() :: {stdin, InputLine :: binary() | eof}.
-type command_message() :: {start, LastResult :: term()} | command_output() | command_exit() | {message, Msg :: term()}.
-type continue_return() :: {continue, NewState :: term()} | {continue, Inputs :: command_input_data(), NewState :: term()}.
-type data_handler() :: fun((State :: term(), command_output()) -> continue_return() | ok_return() | call_return() | error_return()).
-type deep_call_list() :: [call_spec() | command_handler() | deep_call_list()].
-type exit_handler() :: fun((State :: term(), command_exit()) -> ok_return() | call_return() | error_return()).
-type full_command_handler() :: fun((State :: term(), call_spec(), command_message()) -> continue_return() | ok_return() | call_return() | error_return()).
-type log_event() :: {exec, Args :: [binary()]} | command_input() | command_output() | command_exit() | {result, term()} | {error, term()}.
-type log_handler() :: stateless_log_handler() | statefull_log_handler().
-type simple_command_handler() :: fun((State :: term(), LastResult :: term()) -> ok_return() | call_return() | error_return()).
-type start_handler() :: fun((State :: term(), LastResult :: term()) -> continue_return() | ok_return() | call_return() | error_return()).
-type stateless_log_handler() :: fun((log_event()) -> ok).
Functions
-spec command(term(), call_spec() | deep_call_list()) -> ok_return() | call_return().
-spec log(term()) -> ok.