Mix.Shell.Process

This is a Mix shell that uses the current process mailbox for communication instead of IO.

When a developer calls info("hello"), the following message will be sent to the current process:

{ :mix_shell, :info, ["hello"] }

This is mainly useful in tests, allowing us to assert if given messages were received or not. Since we need to guarantee a clean slate between tests, there is also a flush/1 function responsible for flushing all :mix_shell related messages from the process inbox.

Source

Summary

cmd(command)

Executes the given command and fowards its messages to the current process

error(message)

Forwards the message to the current process

flush(callback \\ fn x -> x end)

Flush all :mix_shell and :mix_shell_input messages from the current process. If a callback is given, it is invoked for each received message

info(message)

Forwards the message to the current process

yes?(message)

Forwards the message to the current process. It also checks the inbox for an input message matching:

Functions

cmd(command)

Executes the given command and fowards its messages to the current process.

Source
error(message)

Forwards the message to the current process.

Source
flush(callback \\ fn x -> x end)

Flush all :mix_shell and :mix_shell_input messages from the current process. If a callback is given, it is invoked for each received message.

Examples

flush &IO.inspect(&1)
Source
info(message)

Forwards the message to the current process.

Source
yes?(message)

Forwards the message to the current process. It also checks the inbox for an input message matching:

{ :mix_shell_input, :yes?, value }

If one does not exist, it will abort since there no shell process inputs given. Value must be true or false.

Source