Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-release > by-pkgid > 016232f1d9a3f7bee85855d35a2bca58 > files > 254

elixir-doc-1.7.2-1.mga7.noarch.rpm

<!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>run – Mix v1.7.2</title>
    <link rel="stylesheet" href="dist/app-240d7fc7e5.css" />
      <link rel="canonical" href="https://hexdocs.pm/mix/v1.7/Mix.Tasks.Run.html" />
    <script src="dist/sidebar_items-0c0044e6e4.js"></script>
    
  </head>
  <body data-type="tasks">
    <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 run        
          <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/tasks/run.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>Starts the current application and runs code.</p>
<p><code class="inline">mix run</code> can be used to start the current application dependencies,
the application itself, and optionally run some code in its context.
For long running systems, this is typically done with the <code class="inline">--no-halt</code>
option:</p>
<pre><code class="nohighlight makeup elixir"><span class="n">mix</span><span class="w"> </span><span class="n">run</span><span class="w"> </span><span class="o">--</span><span class="n">no</span><span class="o">-</span><span class="n">halt</span></code></pre>
<p>Once the current application and its dependencies have been started,
you can run a script in its context by passing a filename:</p>
<pre><code class="nohighlight makeup elixir"><span class="n">mix</span><span class="w"> </span><span class="n">run</span><span class="w"> </span><span class="n">my_app_script</span><span class="o">.</span><span class="n">exs</span><span class="w"> </span><span class="n">arg1</span><span class="w"> </span><span class="n">arg2</span><span class="w"> </span><span class="n">arg3</span></code></pre>
<p>Code to be executed can also be passed inline with the <code class="inline">-e</code> option:</p>
<pre><code class="nohighlight makeup elixir"><span class="n">mix</span><span class="w"> </span><span class="n">run</span><span class="w"> </span><span class="o">-</span><span class="n">e</span><span class="w"> </span><span class="s">&quot;DbUtils.delete_old_records()&quot;</span><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="n">arg1</span><span class="w"> </span><span class="n">arg2</span><span class="w"> </span><span class="n">arg3</span></code></pre>
<p>In both cases, the command-line arguments for the script or expression
are available in <a href="https://hexdocs.pm/elixir/System.html#argv/0"><code class="inline">System.argv/0</code></a>.</p>
<p>Before doing anything, Mix will compile the current application if
needed, unless you pass <code class="inline">--no-compile</code>.</p>
<p>If for some reason the application needs to be configured before it is
started, the <code class="inline">--no-start</code> flag can be used and you are then responsible
for starting all applications by using functions such as
<a href="https://hexdocs.pm/elixir/Application.html#ensure_all_started/1"><code class="inline">Application.ensure_all_started/1</code></a>. For more information about the
application life-cycle and dynamically configuring applications, see
the <a href="https://hexdocs.pm/elixir/Application.html"><code class="inline">Application</code></a> module.</p>
<p>If you need to pass options to the Elixir executable at the same time
you use <code class="inline">mix run</code>, it can be done as follows:</p>
<pre><code class="nohighlight makeup elixir"><span class="n">elixir</span><span class="w"> </span><span class="o">--</span><span class="n">sname</span><span class="w"> </span><span class="n">hello</span><span class="w"> </span><span class="o">-</span><span class="nc">S</span><span class="w"> </span><span class="n">mix</span><span class="w"> </span><span class="n">run</span><span class="w"> </span><span class="o">--</span><span class="n">no</span><span class="o">-</span><span class="n">halt</span></code></pre>
<p>This task is automatically reenabled, so it can be called multiple times
with different arguments.</p>
<h2 id="module-command-line-options" class="section-heading">
  <a href="#module-command-line-options" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Command-line options
</h2>

<ul>
<li><code class="inline">--config</code>, <code class="inline">-c</code>  - loads the given configuration file
</li>
<li><code class="inline">--eval</code>, <code class="inline">-e</code> - evaluates the given code
</li>
<li><code class="inline">--require</code>, <code class="inline">-r</code> - executes the given pattern/file
</li>
<li><code class="inline">--parallel</code>, <code class="inline">-p</code> - makes all requires parallel
</li>
<li><code class="inline">--preload-modules</code> - preloads all modules defined in applications
</li>
<li><code class="inline">--no-compile</code> - does not compile even if files require compilation
</li>
<li><code class="inline">--no-deps-check</code> - does not check dependencies
</li>
<li><code class="inline">--no-archives-check</code> - does not check archives
</li>
<li><code class="inline">--no-halt</code> - does not halt the system after running the command
</li>
<li><code class="inline">--no-mix-exs</code> - allows the command to run even if there is no mix.exs
</li>
<li><code class="inline">--no-start</code> - does not start applications after compilation
</li>
<li><code class="inline">--no-elixir-version-check</code> - does not check the Elixir version from mix.exs
</li>
</ul>
        </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="#run/1">run(args)</a>
  </div>
    <div class="summary-synopsis"><p>A task needs to implement <code class="inline">run</code> which receives
a list of command line args</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="run/1">
    <div class="detail-header">
    <a href="#run/1" 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">run(args)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/tasks/run.ex#L63" 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>A task needs to implement <code class="inline">run</code> which receives
a list of command line args.</p>
<p>Callback implementation for <a href="Mix.Task.html#c:run/1"><code class="inline">Mix.Task.run/1</code></a>.</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>