miller/docs6/docs/_build/html/customization.html

131 lines
No EOL
9.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Customization: .mlrrc &#8212; Miller 6.0.0-alpha documentation</title>
<link rel="stylesheet" href="_static/scrolls.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/print.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<script src="_static/theme_extras.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="The REPL" href="repl.html" />
<link rel="prev" title="Output colorization" href="output-colorization.html" />
</head><body>
<div id="content">
<div class="header">
<h1 class="heading"><a href="index.html"
title="back to the documentation overview"><span>Customization: .mlrrc</span></a></h1>
</div>
<div class="relnav" role="navigation" aria-label="related navigation">
<a href="output-colorization.html">&laquo; Output colorization</a> |
<a href="#">Customization: .mlrrc</a>
| <a href="repl.html">The REPL &raquo;</a>
</div>
<div id="contentwrapper">
<div id="toc" role="navigation" aria-label="table of contents navigation">
<h3>Table of Contents</h3>
<ul>
<li><a class="reference internal" href="#">Customization: .mlrrc</a><ul>
<li><a class="reference internal" href="#how-to-use-mlrrc">How to use .mlrrc</a></li>
<li><a class="reference internal" href="#what-you-can-put-in-your-mlrrc">What you can put in your .mlrrc</a></li>
<li><a class="reference internal" href="#where-to-put-your-mlrrc">Where to put your .mlrrc</a></li>
</ul>
</li>
</ul>
</div>
<div role="main">
<div class="section" id="customization-mlrrc">
<h1>Customization: .mlrrc<a class="headerlink" href="#customization-mlrrc" title="Permalink to this headline"></a></h1>
<div class="section" id="how-to-use-mlrrc">
<h2>How to use .mlrrc<a class="headerlink" href="#how-to-use-mlrrc" title="Permalink to this headline"></a></h2>
<p>Suppose you always use CSV files. Then instead of always having to type <code class="docutils literal notranslate"><span class="pre">--csv</span></code> as in</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span><span class="hll"> mlr --csv cut -x -f extra mydata.csv
</span></pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span><span class="hll"> mlr --csv sort -n id mydata.csv
</span></pre></div>
</div>
<p>and so on, you can instead put the following into your <code class="docutils literal notranslate"><span class="pre">$HOME/.mlrrc</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>--csv
</pre></div>
</div>
<p>Then you can just type things like</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span><span class="hll"> mlr cut -x -f extra mydata.csv
</span></pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span><span class="hll"> mlr sort -n id mydata.csv
</span></pre></div>
</div>
<p>and the <code class="docutils literal notranslate"><span class="pre">--csv</span></code> part will automatically be understood. (If you do want to process, say, a JSON file then <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">--json</span> <span class="pre">...</span></code> at the command line will override the default from your <code class="docutils literal notranslate"><span class="pre">.mlrrc</span></code>.)</p>
</div>
<div class="section" id="what-you-can-put-in-your-mlrrc">
<h2>What you can put in your .mlrrc<a class="headerlink" href="#what-you-can-put-in-your-mlrrc" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>You can include any command-line flags, except the “terminal” ones such as <code class="docutils literal notranslate"><span class="pre">--help</span></code>.</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">--prepipe</span></code>, <code class="docutils literal notranslate"><span class="pre">--load</span></code>, and <code class="docutils literal notranslate"><span class="pre">--mload</span></code> flags arent allowed in <code class="docutils literal notranslate"><span class="pre">.mlrrc</span></code> as they control code execution, and could result in your scripts running things you dont expect if you receive data from someone with a <code class="docutils literal notranslate"><span class="pre">.mlrrc</span></code> in it.</p></li>
<li><p>The formatting rule is you need to put one flag beginning with <code class="docutils literal notranslate"><span class="pre">--</span></code> per line: for example, <code class="docutils literal notranslate"><span class="pre">--csv</span></code> on one line and <code class="docutils literal notranslate"><span class="pre">--nr-progress-mod</span> <span class="pre">1000</span></code> on a separate line.</p></li>
<li><p>Since every line starts with a <code class="docutils literal notranslate"><span class="pre">--</span></code> option, you can leave off the initial <code class="docutils literal notranslate"><span class="pre">--</span></code> if you want. For example, <code class="docutils literal notranslate"><span class="pre">ojson</span></code> is the same as <code class="docutils literal notranslate"><span class="pre">--ojson</span></code>, and <code class="docutils literal notranslate"><span class="pre">nr-progress-mod</span> <span class="pre">1000</span></code> is the same as <code class="docutils literal notranslate"><span class="pre">--nr-progress-mod</span> <span class="pre">1000</span></code>.</p></li>
<li><p>Comments are from a <code class="docutils literal notranslate"><span class="pre">#</span></code> to the end of the line.</p></li>
<li><p>Empty lines are ignored including lines which are empty after comments are removed.</p></li>
</ul>
<p>Here is an example <code class="docutils literal notranslate"><span class="pre">.mlrrc</span></code> file:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span># Input and output formats are CSV by default (unless otherwise specified
# on the mlr command line):
csv
# If a data line has fewer fields than the header line, instead of erroring
# (which is the default), just insert empty values for the missing ones:
allow-ragged-csv-input
# These are no-ops for CSV, but when I do use JSON output, I want these
# pretty-printing options to be used:
jvstack
jlistwrap
# Use &quot;@&quot;, rather than &quot;#&quot;, for comments within data files:
skip-comments-with @
</pre></div>
</div>
</div>
<div class="section" id="where-to-put-your-mlrrc">
<h2>Where to put your .mlrrc<a class="headerlink" href="#where-to-put-your-mlrrc" title="Permalink to this headline"></a></h2>
<p>If the environment variable <code class="docutils literal notranslate"><span class="pre">MLRRC</span></code> is set:</p>
<ul class="simple">
<li><p>If its value is <code class="docutils literal notranslate"><span class="pre">__none__</span></code> then no <code class="docutils literal notranslate"><span class="pre">.mlrrc</span></code> files are processed. (This is nice for things like regression testing.)</p></li>
<li><p>Otherwise, its value (as a filename) is loaded and processed. If there are syntax errors, they abort <code class="docutils literal notranslate"><span class="pre">mlr</span></code> with a usage message (as if you had mistyped something on the command line). If the file cant be loaded at all, though, it is silently skipped.</p></li>
<li><p>Any <code class="docutils literal notranslate"><span class="pre">.mlrrc</span></code> in your home directory or current directory is ignored whenever <code class="docutils literal notranslate"><span class="pre">MLRRC</span></code> is set in the environment.</p></li>
<li><p>Example line in your shells rc file: <code class="docutils literal notranslate"><span class="pre">export</span> <span class="pre">MLRRC=/path/to/my/mlrrc</span></code></p></li>
</ul>
<p>Otherwise:</p>
<ul class="simple">
<li><p>If <code class="docutils literal notranslate"><span class="pre">$HOME/.mlrrc</span></code> exists, its processed as above.</p></li>
<li><p>If <code class="docutils literal notranslate"><span class="pre">./.mlrrc</span></code> exists, its then also processed as above.</p></li>
<li><p>The idea is you can have all your settings in your <code class="docutils literal notranslate"><span class="pre">$HOME/.mlrrc</span></code>, then override maybe one or two for your current directory if you like.</p></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2021, John Kerl.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>