Mix v1.5.2 Mix.Shell behaviour View Source

Defines Mix.Shell contract.

Link to this section Summary

Functions

An implementation of the command callback that is shared across different shells

Returns the printable app name

Callbacks

Executes the given command and returns its exit status

Executes the given command and returns its exit status

Prints the given error to the shell

Prints the given message to the shell

Prints the current application to the shell if it was not printed yet

Prompts the user for input

Prompts the user for confirmation

Link to this section Functions

Link to this function cmd(command, options \\ [], callback) View Source

An implementation of the command callback that is shared across different shells.

Returns the printable app name.

This function returns the current application name, but only if the application name should be printed.

Calling this function automatically toggles its value to false until the current project is re-entered. The goal is to avoid printing the application name multiple times.

Link to this section Callbacks

Link to this callback cmd(command) View Source
cmd(command :: String.t()) :: integer()

Executes the given command and returns its exit status.

Link to this callback cmd(command, options) View Source
cmd(command :: String.t(), options :: keyword()) :: integer()

Executes the given command and returns its exit status.

Options

  • :print_app - when false, does not print the app name when the command outputs something

  • :stderr_to_stdout - when false, does not redirect stderr to stdout

  • :quiet - when true, do not print the command output

  • :env - environment options to the executed command

Link to this callback error(message) View Source
error(message :: IO.ANSI.ansidata()) :: any()

Prints the given error to the shell.

Link to this callback info(message) View Source
info(message :: IO.ANSI.ansidata()) :: any()

Prints the given message to the shell.

Link to this callback print_app() View Source
print_app() :: any()

Prints the current application to the shell if it was not printed yet.

Link to this callback prompt(message) View Source
prompt(message :: String.t()) :: String.t()

Prompts the user for input.

Link to this callback yes?(message) View Source
yes?(message :: String.t()) :: boolean()

Prompts the user for confirmation.