CliMate.ProcessShell (CLI Mate v0.7.1)

View Source

An output shell implementation allowing your CLI commands to send their output as messages to themselves. This is most useful for tests.

The process that will receive the messages is found by looking up the first pid in the :"$callers" key of the process dictionary, or self() if there is no caller.

Use CliMate.put_shell(CliMate.ProcessShell) to enable this shell.

This shell is called when calling one of:

  • CliMate.CLI.error/1 *CliMate.CLI.warn/1
  • CliMate.CLI.debug/1 *CliMate.CLI.success/1
  • CliMate.CLI.writeln/1 *CliMate.CLI.halt_success/1
  • CliMate.CLI.halt_error/1 *CliMate.CLI.halt_error/2

A message of type shell_message/0 will be sent to self(), or the caller process for Task.async/1 and similar task functions.

Summary

Functions

Returns the pid of the process that will receive output messages.

Types

kind()

@type kind() :: :error | :warn | :debug | :info

shell_message()

@type shell_message() :: {:cli_mate_shell, kind(), iodata()}

Functions

build_message(kind, iodata)

@spec build_message(kind(), iodata()) :: {:cli_mate_shell, kind(), iodata()}

message_target()

Returns the pid of the process that will receive output messages.