Mix v1.0.5 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.

Summary

Functions

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

Forwards the message to the current process

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

Forwards the message to the current process

Prints the currently running application if it was not printed yet

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

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

Functions

cmd(command, opts \\ [])

Executes the given command and forwards 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.

Examples

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

Forwards the message to the current process.

prompt(message)

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

{:mix_shell_input, :prompt, value}

If one does not exist, it will abort since there was no shell process inputs given. Value must be a string.

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 was no shell process inputs given. Value must be true or false.