Files
SwiftShell/Functions.html
2019-03-28 15:49:36 +01:00

1030 lines
54 KiB
HTML
Raw Permalink 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 lang="en">
<head>
<title>Functions Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset='utf-8'>
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Section/Functions" class="dashAnchor"></a>
<a title="Functions Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html">SwiftShell Docs</a> (72% documented)</p>
<p class="header-right"><a href="https://github.com/kareman/SwiftShell"><img src="img/gh.png"/>View on GitHub</a></p>
</div>
</header>
<div class="content-wrapper">
<p id="breadcrumbs">
<a href="index.html">SwiftShell Reference</a>
<img id="carat" src="img/carat.png" />
Functions Reference
</p>
</div>
<div class="content-wrapper">
<nav class="sidebar">
<ul class="nav-groups">
<li class="nav-group-name">
<a href="Classes.html">Classes</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Classes/AsyncCommand.html">AsyncCommand</a>
</li>
<li class="nav-group-task">
<a href="Classes/FileHandleStream.html">FileHandleStream</a>
</li>
<li class="nav-group-task">
<a href="Classes/MainContext.html">MainContext</a>
</li>
<li class="nav-group-task">
<a href="Classes/PrintedAsyncCommand.html">PrintedAsyncCommand</a>
</li>
<li class="nav-group-task">
<a href="Classes/RunOutput.html">RunOutput</a>
</li>
<li class="nav-group-task">
<a href="Classes/StdoutStream.html">StdoutStream</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Global Variables.html">Global Variables</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Global Variables.html#/s:10SwiftShell5FilesSo13NSFileManagerCvp">Files</a>
</li>
<li class="nav-group-task">
<a href="Global Variables.html#/s:10SwiftShell4mainAA11MainContextCvp">main</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Enums/CommandError.html">CommandError</a>
</li>
<li class="nav-group-task">
<a href="Enums/FileError.html">FileError</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Extensions.html">Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Extensions/FileHandle.html">FileHandle</a>
</li>
<li class="nav-group-task">
<a href="Extensions/FileHandle.html">FileHandle</a>
</li>
<li class="nav-group-task">
<a href="Extensions/LazyCollectionProtocol.html">LazyCollectionProtocol</a>
</li>
<li class="nav-group-task">
<a href="Extensions/Process.html">Process</a>
</li>
<li class="nav-group-task">
<a href="Extensions/Process.html">Process</a>
</li>
<li class="nav-group-task">
<a href="Extensions/String.html">String</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Functions.html">Functions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell1poiy10Foundation3URLVAE_SStF">+(_:_:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell4exit_4file4lines5NeverOs5Error_p_SSSitF">exit(_:file:line:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell4exit12errormessage9errorcode4file4lines5NeverOx_SiSSSitlF">exit(errormessage:errorcode:file:line:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell4open_8encodingAA14ReadableStream_p10Foundation3URLV_SSAEE8EncodingVtKF">open(_:encoding:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell4open_8encodingAA14ReadableStream_pSS_SS10FoundationE8EncodingVtKF">open(_:encoding:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell4open10forWriting9overwrite8encodingAA14WritableStream_p10Foundation3URLV_SbSSAGE8EncodingVtKF">open(forWriting:overwrite:encoding:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell4open10forWriting9overwrite8encodingAA14WritableStream_pSS_SbSS10FoundationE8EncodingVtKF">open(forWriting:overwrite:encoding:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell3run__13combineOutputAA03RunE0CSS_ypdSbtF">run(_:_:combineOutput:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell3run4bash13combineOutputAA03RunF0CSS_SbtF">run(bash:combineOutput:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell11runAndPrintyySS_ypdtKF">runAndPrint(_:_:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell11runAndPrint4bashySS_tKF">runAndPrint(bash:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell8runAsync__4file4lineAA0D7CommandCSS_ypdSSSitF">runAsync(_:_:file:line:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell8runAsync4bash4file4lineAA0D7CommandCSS_SSSitF">runAsync(bash:file:line:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell16runAsyncAndPrint__4file4lineAA07PrintedD7CommandCSS_ypdSSSitF">runAsyncAndPrint(_:_:file:line:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell16runAsyncAndPrint4bash4file4lineAA07PrintedD7CommandCSS_SSSitF">runAsyncAndPrint(bash:file:line:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:10SwiftShell7streamsAA14WritableStream_p_AA08ReadableE0_ptyF">streams()</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Protocols.html#/CommandRunning">CommandRunning</a>
</li>
<li class="nav-group-task">
<a href="Protocols/CommandRunning.html">CommandRunning</a>
</li>
<li class="nav-group-task">
<a href="Protocols/Context.html">Context</a>
</li>
<li class="nav-group-task">
<a href="Protocols/ReadableStream.html">ReadableStream</a>
</li>
<li class="nav-group-task">
<a href="Protocols/WritableStream.html">WritableStream</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Structs/CustomContext.html">CustomContext</a>
</li>
<li class="nav-group-task">
<a href="Structs/LazySplitSequence.html">LazySplitSequence</a>
</li>
<li class="nav-group-task">
<a href="Structs/PartialSourceLazySplitSequence.html">PartialSourceLazySplitSequence</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section>
<section class="section">
<h1>Functions</h1>
<p>The following functions are available globally.</p>
</section>
<section class="section task-group-section">
<div class="task-group">
<div class="task-name-container">
<a name="/Bash"></a>
<a name="//apple_ref/swift/Section/Bash" class="dashAnchor"></a>
<a href="#/Bash">
<h3 class="section-name">Bash</h3>
</a>
</div>
<ul>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell3run4bash13combineOutputAA03RunF0CSS_SbtF"></a>
<a name="//apple_ref/swift/Function/run(bash:combineOutput:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell3run4bash13combineOutputAA03RunF0CSS_SbtF">run(bash:combineOutput:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Runs a bash shell command.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">@discardableResult</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="nf">run</span><span class="p">(</span><span class="n">bash</span> <span class="nv">bashcommand</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">combineOutput</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">false</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="Classes/RunOutput.html">RunOutput</a></span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>bashcommand</em>
</code>
</td>
<td>
<div>
<p>the bash shell command.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>combineOutput</em>
</code>
</td>
<td>
<div>
<p>if true then stdout and stderror go to the same stream. Default is false.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell8runAsync4bash4file4lineAA0D7CommandCSS_SSSitF"></a>
<a name="//apple_ref/swift/Function/runAsync(bash:file:line:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell8runAsync4bash4file4lineAA0D7CommandCSS_SSSitF">runAsync(bash:file:line:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Runs bash command and returns before it is finished.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">runAsync</span><span class="p">(</span><span class="n">bash</span> <span class="nv">bashcommand</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">file</span><span class="p">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="kd">#file</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="kd">#line</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="Classes/AsyncCommand.html">AsyncCommand</a></span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>bashcommand</em>
</code>
</td>
<td>
<div>
<p>the bash shell command.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell16runAsyncAndPrint4bash4file4lineAA07PrintedD7CommandCSS_SSSitF"></a>
<a name="//apple_ref/swift/Function/runAsyncAndPrint(bash:file:line:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell16runAsyncAndPrint4bash4file4lineAA07PrintedD7CommandCSS_SSSitF">runAsyncAndPrint(bash:file:line:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Runs bash command and returns before it is finished.
Any output is printed to standard output and standard error, respectively.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">runAsyncAndPrint</span><span class="p">(</span><span class="n">bash</span> <span class="nv">bashcommand</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">file</span><span class="p">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="kd">#file</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="kd">#line</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="Classes/PrintedAsyncCommand.html">PrintedAsyncCommand</a></span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>bashcommand</em>
</code>
</td>
<td>
<div>
<p>the bash shell command.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell11runAndPrint4bashySS_tKF"></a>
<a name="//apple_ref/swift/Function/runAndPrint(bash:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell11runAndPrint4bashySS_tKF">runAndPrint(bash:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Runs bash command and prints output and errors.</p>
<div class="aside aside-throws">
<p class="aside-title">Throws</p>
a CommandError.returnedErrorCode if the return code is anything but 0.
</div>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">runAndPrint</span><span class="p">(</span><span class="n">bash</span> <span class="nv">bashcommand</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="k">throws</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>bashcommand</em>
</code>
</td>
<td>
<div>
<p>the bash shell command.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<div class="task-name-container">
<a name="/exit"></a>
<a name="//apple_ref/swift/Section/exit" class="dashAnchor"></a>
<a href="#/exit">
<h3 class="section-name">exit</h3>
</a>
</div>
<ul>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell4exit12errormessage9errorcode4file4lines5NeverOx_SiSSSitlF"></a>
<a name="//apple_ref/swift/Function/exit(errormessage:errorcode:file:line:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell4exit12errormessage9errorcode4file4lines5NeverOx_SiSSSitlF">exit(errormessage:errorcode:file:line:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Prints message to standard error and terminates the application.</p>
<p>In debug builds it precedes the message with filename and line number.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="n">exit</span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;</span><span class="p">(</span><span class="nv">errormessage</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">errorcode</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="nv">file</span><span class="p">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="kd">#file</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="kd">#line</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Never</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>errormessage</em>
</code>
</td>
<td>
<div>
<p>the error message.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>errorcode</em>
</code>
</td>
<td>
<div>
<p>exit code for the entire program. Defaults to 1.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<h4>Return Value</h4>
<p>Never.</p>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell4exit_4file4lines5NeverOs5Error_p_SSSitF"></a>
<a name="//apple_ref/swift/Function/exit(_:file:line:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell4exit_4file4lines5NeverOs5Error_p_SSSitF">exit(_:file:line:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Prints error to standard error and terminates the application.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">exit</span><span class="p">(</span><span class="n">_</span> <span class="nv">error</span><span class="p">:</span> <span class="kt">Error</span><span class="p">,</span> <span class="nv">file</span><span class="p">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="kd">#file</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="kd">#line</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Never</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>error</em>
</code>
</td>
<td>
<div>
<p>the error</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<h4>Return Value</h4>
<p>Never.</p>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<div class="task-name-container">
<a name="/Global%20functions"></a>
<a name="//apple_ref/swift/Section/Global functions" class="dashAnchor"></a>
<a href="#/Global%20functions">
<h3 class="section-name">Global functions</h3>
</a>
</div>
<ul>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell3run__13combineOutputAA03RunE0CSS_ypdSbtF"></a>
<a name="//apple_ref/swift/Function/run(_:_:combineOutput:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell3run__13combineOutputAA03RunE0CSS_ypdSbtF">run(_:_:combineOutput:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Runs a command.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">@discardableResult</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="nf">run</span><span class="p">(</span><span class="n">_</span> <span class="nv">executable</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="n">_</span> <span class="nv">args</span><span class="p">:</span> <span class="kt">Any</span><span class="o">...</span><span class="p">,</span> <span class="nv">combineOutput</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">false</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="Classes/RunOutput.html">RunOutput</a></span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>executable</em>
</code>
</td>
<td>
<div>
<p>path to an executable, or the name of an executable in PATH.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>args</em>
</code>
</td>
<td>
<div>
<p>the arguments, one string for each.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>combineOutput</em>
</code>
</td>
<td>
<div>
<p>if true then stdout and stderror go to the same stream. Default is false.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell8runAsync__4file4lineAA0D7CommandCSS_ypdSSSitF"></a>
<a name="//apple_ref/swift/Function/runAsync(_:_:file:line:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell8runAsync__4file4lineAA0D7CommandCSS_ypdSSSitF">runAsync(_:_:file:line:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Runs executable and returns before it is finished.</p>
<div class="aside aside-warning">
<p class="aside-title">Warning</p>
Application will be terminated if executable could not be launched.
</div>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">runAsync</span><span class="p">(</span><span class="n">_</span> <span class="nv">executable</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="n">_</span> <span class="nv">args</span><span class="p">:</span> <span class="kt">Any</span><span class="o">...</span><span class="p">,</span> <span class="nv">file</span><span class="p">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="kd">#file</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="kd">#line</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="Classes/AsyncCommand.html">AsyncCommand</a></span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>executable</em>
</code>
</td>
<td>
<div>
<p>Path to an executable file. If not then exit.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>args</em>
</code>
</td>
<td>
<div>
<p>Arguments to the executable.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell16runAsyncAndPrint__4file4lineAA07PrintedD7CommandCSS_ypdSSSitF"></a>
<a name="//apple_ref/swift/Function/runAsyncAndPrint(_:_:file:line:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell16runAsyncAndPrint__4file4lineAA07PrintedD7CommandCSS_ypdSSSitF">runAsyncAndPrint(_:_:file:line:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Runs executable and returns before it is finished.
Any output is printed to standard output and standard error, respectively.</p>
<div class="aside aside-warning">
<p class="aside-title">Warning</p>
Application will be terminated if executable could not be launched.
</div>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">runAsyncAndPrint</span><span class="p">(</span><span class="n">_</span> <span class="nv">executable</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="n">_</span> <span class="nv">args</span><span class="p">:</span> <span class="kt">Any</span><span class="o">...</span><span class="p">,</span> <span class="nv">file</span><span class="p">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="kd">#file</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="kd">#line</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="Classes/PrintedAsyncCommand.html">PrintedAsyncCommand</a></span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>executable</em>
</code>
</td>
<td>
<div>
<p>Path to an executable file. If not then exit.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>args</em>
</code>
</td>
<td>
<div>
<p>Arguments to the executable.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell11runAndPrintyySS_ypdtKF"></a>
<a name="//apple_ref/swift/Function/runAndPrint(_:_:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell11runAndPrintyySS_ypdtKF">runAndPrint(_:_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Runs executable and prints output and errors.</p>
<div class="aside aside-throws">
<p class="aside-title">Throws</p>
<p><code>CommandError.returnedErrorCode(command: String, errorcode: Int)</code> if the exit code is anything but 0.</p>
<p><code>CommandError.inAccessibleExecutable(path: String)</code> if &lsquo;executable turned out to be not so executable after all.</p>
</div>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">runAndPrint</span><span class="p">(</span><span class="n">_</span> <span class="nv">executable</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="n">_</span> <span class="nv">args</span><span class="p">:</span> <span class="kt">Any</span><span class="o">...</span><span class="p">)</span> <span class="k">throws</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>executable</em>
</code>
</td>
<td>
<div>
<p>path to an executable file.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>args</em>
</code>
</td>
<td>
<div>
<p>arguments to the executable.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell1poiy10Foundation3URLVAE_SStF"></a>
<a name="//apple_ref/swift/Function/+(_:_:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell1poiy10Foundation3URLVAE_SStF">+(_:_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appends file or directory url to directory url</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="o">+</span> <span class="p">(</span><span class="nv">leftpath</span><span class="p">:</span> <span class="kt">URL</span><span class="p">,</span> <span class="nv">rightpath</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">URL</span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell4open_8encodingAA14ReadableStream_pSS_SS10FoundationE8EncodingVtKF"></a>
<a name="//apple_ref/swift/Function/open(_:encoding:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell4open_8encodingAA14ReadableStream_pSS_SS10FoundationE8EncodingVtKF">open(_:encoding:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Opens a file for reading, throws if an error occurs.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">open</span><span class="p">(</span><span class="n">_</span> <span class="nv">path</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">encoding</span><span class="p">:</span> <span class="kt">String</span><span class="o">.</span><span class="kt">Encoding</span> <span class="o">=</span> <span class="n"><a href="Global Variables.html#/s:10SwiftShell4mainAA11MainContextCvp">main</a></span><span class="o">.</span><span class="n">encoding</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt"><a href="Protocols/ReadableStream.html">ReadableStream</a></span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell4open_8encodingAA14ReadableStream_p10Foundation3URLV_SSAEE8EncodingVtKF"></a>
<a name="//apple_ref/swift/Function/open(_:encoding:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell4open_8encodingAA14ReadableStream_p10Foundation3URLV_SSAEE8EncodingVtKF">open(_:encoding:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Opens a file for reading, throws if an error occurs.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">open</span><span class="p">(</span><span class="n">_</span> <span class="nv">path</span><span class="p">:</span> <span class="kt">URL</span><span class="p">,</span> <span class="nv">encoding</span><span class="p">:</span> <span class="kt">String</span><span class="o">.</span><span class="kt">Encoding</span> <span class="o">=</span> <span class="n"><a href="Global Variables.html#/s:10SwiftShell4mainAA11MainContextCvp">main</a></span><span class="o">.</span><span class="n">encoding</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt"><a href="Protocols/ReadableStream.html">ReadableStream</a></span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell4open10forWriting9overwrite8encodingAA14WritableStream_p10Foundation3URLV_SbSSAGE8EncodingVtKF"></a>
<a name="//apple_ref/swift/Function/open(forWriting:overwrite:encoding:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell4open10forWriting9overwrite8encodingAA14WritableStream_p10Foundation3URLV_SbSSAGE8EncodingVtKF">open(forWriting:overwrite:encoding:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Opens a file for writing, creates it first if it doesn&rsquo;t exist.
If the file already exists and overwrite=false, the writing will begin at the end of the file.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">open</span><span class="p">(</span><span class="n">forWriting</span> <span class="nv">path</span><span class="p">:</span> <span class="kt">URL</span><span class="p">,</span> <span class="nv">overwrite</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nv">encoding</span><span class="p">:</span> <span class="kt">String</span><span class="o">.</span><span class="kt">Encoding</span> <span class="o">=</span> <span class="n"><a href="Global Variables.html#/s:10SwiftShell4mainAA11MainContextCvp">main</a></span><span class="o">.</span><span class="n">encoding</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt"><a href="Protocols/WritableStream.html">WritableStream</a></span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>overwrite</em>
</code>
</td>
<td>
<div>
<p>If true, replace the file if it exists.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell4open10forWriting9overwrite8encodingAA14WritableStream_pSS_SbSS10FoundationE8EncodingVtKF"></a>
<a name="//apple_ref/swift/Function/open(forWriting:overwrite:encoding:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell4open10forWriting9overwrite8encodingAA14WritableStream_pSS_SbSS10FoundationE8EncodingVtKF">open(forWriting:overwrite:encoding:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Opens a file for writing, creates it first if it doesn&rsquo;t exist.
If the file already exists and overwrite=false, the writing will begin at the end of the file.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">open</span><span class="p">(</span><span class="n">forWriting</span> <span class="nv">path</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">overwrite</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nv">encoding</span><span class="p">:</span> <span class="kt">String</span><span class="o">.</span><span class="kt">Encoding</span> <span class="o">=</span> <span class="n"><a href="Global Variables.html#/s:10SwiftShell4mainAA11MainContextCvp">main</a></span><span class="o">.</span><span class="n">encoding</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt"><a href="Protocols/WritableStream.html">WritableStream</a></span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>overwrite</em>
</code>
</td>
<td>
<div>
<p>If true, replace the file if it exists.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell7streamsAA14WritableStream_p_AA08ReadableE0_ptyF"></a>
<a name="//apple_ref/swift/Function/streams()" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell7streamsAA14WritableStream_p_AA08ReadableE0_ptyF">streams()</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Creates a pair of streams. What is written to the 1st one can be read from the 2nd one.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">streams</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="kt"><a href="Protocols/WritableStream.html">WritableStream</a></span><span class="p">,</span> <span class="kt"><a href="Protocols/ReadableStream.html">ReadableStream</a></span><span class="p">)</span></code></pre>
</div>
</div>
</section>
</div>
</li>
</ul>
</div>
</section>
</section>
<section id="footer">
<p>&copy; 2019 <a class="link" href="" target="_blank" rel="external">kareman</a>. All rights reserved. (Last updated: 2019-03-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.5</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>
</body>
</div>
</html>