<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="generator" content="ExDoc v0.19.1"> <title>Mix.Shell – Mix v1.7.2</title> <link rel="stylesheet" href="dist/app-240d7fc7e5.css" /> <link rel="canonical" href="https://hexdocs.pm/mix/v1.7/Mix.Shell.html" /> <script src="dist/sidebar_items-0c0044e6e4.js"></script> </head> <body data-type="modules"> <script>try { if(localStorage.getItem('night-mode')) document.body.className += ' night-mode'; } catch (e) { }</script> <div class="main"> <button class="sidebar-button sidebar-toggle"> <span class="icon-menu" aria-hidden="true"></span> <span class="sr-only">Toggle Sidebar</span> </button> <button class="sidebar-button night-mode-toggle"> <span class="icon-theme" aria-hidden="true"></span> <span class="sr-only">Toggle Theme</span> </button> <section class="sidebar"> <a href="http://elixir-lang.org/docs.html" class="sidebar-projectLink"> <div class="sidebar-projectDetails"> <h1 class="sidebar-projectName"> Mix </h1> <h2 class="sidebar-projectVersion"> v1.7.2 </h2> </div> <img src="assets/logo.png" alt="Mix" class="sidebar-projectImage"> </a> <form class="sidebar-search" action="search.html"> <button type="submit" class="search-button"> <span class="icon-search" aria-hidden="true"></span> </button> <input name="q" type="text" id="search-list" class="search-input" placeholder="Search" aria-label="Search" autocomplete="off" /> </form> <ul class="sidebar-listNav"> <li><a id="extras-list" href="#full-list">Pages</a></li> <li><a id="modules-list" href="#full-list">Modules</a></li> <li><a id="exceptions-list" href="#full-list">Exceptions</a></li> <li><a id="tasks-list" href="#full-list">Mix Tasks</a></li> </ul> <div class="gradient"></div> <ul id="full-list" class="sidebar-fullList"></ul> </section> <section class="content"> <div class="content-outer"> <div id="content" class="content-inner"> <h1> <small class="visible-xs">Mix v1.7.2</small> Mix.Shell <small>behaviour</small> <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/shell.ex#L1" title="View Source" class="view-source" rel="help"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> </h1> <section id="moduledoc"> <p>Defines <a href="Mix.Shell.html#content"><code class="inline">Mix.Shell</code></a> contract.</p> </section> <section id="summary" class="details-list"> <h1 class="section-heading"> <a class="hover-link" href="#summary"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this section</span> </a> Summary </h1> <div class="summary-functions summary"> <h2> <a href="#functions">Functions</a> </h2> <div class="summary-row"> <div class="summary-signature"> <a href="#cmd/3">cmd(command, options \\ [], callback)</a> </div> <div class="summary-synopsis"><p>Executes the given <code class="inline">command</code> as a shell command and invokes the <code class="inline">callback</code> for the streamed response</p> </div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#printable_app_name/0">printable_app_name()</a> </div> <div class="summary-synopsis"><p>Returns the printable app name</p> </div> </div> </div> <div class="summary-callbacks summary"> <h2> <a href="#callbacks">Callbacks</a> </h2> <div class="summary-row"> <div class="summary-signature"> <a href="#c:cmd/1">cmd(command)</a> </div> <div class="summary-synopsis"><p>Executes the given command and returns its exit status</p> </div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#c:cmd/2">cmd(command, options)</a> </div> <div class="summary-synopsis"><p>Executes the given command and returns its exit status</p> </div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#c:error/1">error(message)</a> </div> <div class="summary-synopsis"><p>Prints the given ANSI error to the shell</p> </div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#c:info/1">info(message)</a> </div> <div class="summary-synopsis"><p>Prints the given ANSI message to the shell</p> </div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#c:print_app/0">print_app()</a> </div> <div class="summary-synopsis"><p>Prints the current application to the shell if it was not printed yet</p> </div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#c:prompt/1">prompt(message)</a> </div> <div class="summary-synopsis"><p>Prompts the user for input</p> </div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#c:yes?/1">yes?(message)</a> </div> <div class="summary-synopsis"><p>Prompts the user for confirmation</p> </div> </div> </div> </section> <section id="functions" class="details-list"> <h1 class="section-heading"> <a class="hover-link" href="#functions"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this section</span> </a> Functions </h1> <div class="detail" id="cmd/3"> <span id="cmd/2"></span> <div class="detail-header"> <a href="#cmd/3" class="detail-link" title="Link to this function"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this function</span> </a> <span class="signature">cmd(command, options \\ [], callback)</span> <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/shell.ex#L84" class="view-source" rel="help" title="View Source"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Executes the given <code class="inline">command</code> as a shell command and invokes the <code class="inline">callback</code> for the streamed response.</p> <p>This is most commonly used by shell implementations but can also be invoked directly.</p> <h2 id="cmd/3-options" class="section-heading"> <a href="#cmd/3-options" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a> Options </h2> <ul> <li><code class="inline">:stderr_to_stdout</code> - redirects stderr to stdout, defaults to true </li> <li><code class="inline">:env</code> - a list of environment variables, defaults to <code class="inline">[]</code> </li> <li><code class="inline">:quiet</code> - overrides the callback to no-op </li> </ul> </section> </div> <div class="detail" id="printable_app_name/0"> <div class="detail-header"> <a href="#printable_app_name/0" class="detail-link" title="Link to this function"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this function</span> </a> <span class="signature">printable_app_name()</span> <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/shell.ex#L66" class="view-source" rel="help" title="View Source"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> </div> <section class="docstring"> <p>Returns the printable app name.</p> <p>This function returns the current application name, but only if the application name should be printed.</p> <p>Calling this function automatically toggles its value to <code class="inline">false</code> until the current project is re-entered. The goal is to avoid printing the application name multiple times.</p> </section> </div> </section> <section id="callbacks" class="details-list"> <h1 class="section-heading"> <a class="hover-link" href="#callbacks"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this section</span> </a> Callbacks </h1> <div class="detail" id="c:cmd/1"> <div class="detail-header"> <a href="#c:cmd/1" class="detail-link" title="Link to this callback"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this callback</span> </a> <span class="signature">cmd(command)</span> <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/shell.ex#L19" class="view-source" rel="help" title="View Source"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> <div class="specs"> <pre>cmd(command :: <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()) :: <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">integer</a>()</pre> </div> </div> <section class="docstring"> <p>Executes the given command and returns its exit status.</p> </section> </div> <div class="detail" id="c:cmd/2"> <div class="detail-header"> <a href="#c:cmd/2" class="detail-link" title="Link to this callback"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this callback</span> </a> <span class="signature">cmd(command, options)</span> <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/shell.ex#L37" class="view-source" rel="help" title="View Source"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> <div class="specs"> <pre>cmd(command :: <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>(), options :: <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">keyword</a>()) :: <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">integer</a>()</pre> </div> </div> <section class="docstring"> <p>Executes the given command and returns its exit status.</p> <h2 id="c:cmd/2-options" class="section-heading"> <a href="#c:cmd/2-options" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a> Options </h2> <ul> <li><p><code class="inline">:print_app</code> - when <code class="inline">false</code>, does not print the app name when the command outputs something</p> </li> <li><p><code class="inline">:stderr_to_stdout</code> - when <code class="inline">false</code>, does not redirect stderr to stdout</p> </li> <li><p><code class="inline">:quiet</code> - when <code class="inline">true</code>, do not print the command output</p> </li> <li><p><code class="inline">:env</code> - environment options to the executed command</p> </li> </ul> </section> </div> <div class="detail" id="c:error/1"> <div class="detail-header"> <a href="#c:error/1" class="detail-link" title="Link to this callback"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this callback</span> </a> <span class="signature">error(message)</span> <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/shell.ex#L14" class="view-source" rel="help" title="View Source"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> <div class="specs"> <pre>error(message :: <a href="https://hexdocs.pm/elixir/IO.ANSI.html#t:ansidata/0">IO.ANSI.ansidata</a>()) :: :ok</pre> </div> </div> <section class="docstring"> <p>Prints the given ANSI error to the shell.</p> </section> </div> <div class="detail" id="c:info/1"> <div class="detail-header"> <a href="#c:info/1" class="detail-link" title="Link to this callback"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this callback</span> </a> <span class="signature">info(message)</span> <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/shell.ex#L9" class="view-source" rel="help" title="View Source"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> <div class="specs"> <pre>info(message :: <a href="https://hexdocs.pm/elixir/IO.ANSI.html#t:ansidata/0">IO.ANSI.ansidata</a>()) :: :ok</pre> </div> </div> <section class="docstring"> <p>Prints the given ANSI message to the shell.</p> </section> </div> <div class="detail" id="c:print_app/0"> <div class="detail-header"> <a href="#c:print_app/0" class="detail-link" title="Link to this callback"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this callback</span> </a> <span class="signature">print_app()</span> <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/shell.ex#L53" class="view-source" rel="help" title="View Source"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> <div class="specs"> <pre>print_app() :: :ok</pre> </div> </div> <section class="docstring"> <p>Prints the current application to the shell if it was not printed yet.</p> </section> </div> <div class="detail" id="c:prompt/1"> <div class="detail-header"> <a href="#c:prompt/1" class="detail-link" title="Link to this callback"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this callback</span> </a> <span class="signature">prompt(message)</span> <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/shell.ex#L42" class="view-source" rel="help" title="View Source"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> <div class="specs"> <pre>prompt(message :: <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">binary</a>()) :: <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">binary</a>()</pre> </div> </div> <section class="docstring"> <p>Prompts the user for input.</p> </section> </div> <div class="detail" id="c:yes?/1"> <div class="detail-header"> <a href="#c:yes?/1" class="detail-link" title="Link to this callback"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this callback</span> </a> <span class="signature">yes?(message)</span> <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/shell.ex#L47" class="view-source" rel="help" title="View Source"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> <div class="specs"> <pre>yes?(message :: <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">binary</a>()) :: <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">boolean</a>()</pre> </div> </div> <section class="docstring"> <p>Prompts the user for confirmation.</p> </section> </div> </section> <footer class="footer"> <p> <span class="line"> Built using <a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" target="_blank" rel="help noopener">ExDoc</a> (v0.19.1), </span> <span class="line"> designed by <a href="https://twitter.com/dignifiedquire" target="_blank" rel="noopener" title="@dignifiedquire">Friedel Ziegelmayer</a>. </span> </p> </footer> </div> </div> </section> </div> <script src="dist/app-a0c90688fa.js"></script> </body> </html>