Files
2019-03-28 15:49:36 +01:00

523 lines
25 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>PrintedAsyncCommand Class 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/Class/PrintedAsyncCommand" class="dashAnchor"></a>
<a title="PrintedAsyncCommand Class 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" />
PrintedAsyncCommand Class 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>PrintedAsyncCommand</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">PrintedAsyncCommand</span></code></pre>
</div>
</div>
<p>Output from the <code>runAsyncAndPrint</code> commands.</p>
</section>
<section class="section task-group-section">
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell19PrintedAsyncCommandC9isRunningSbvp"></a>
<a name="//apple_ref/swift/Property/isRunning" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell19PrintedAsyncCommandC9isRunningSbvp">isRunning</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Is the command still running?</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="k">var</span> <span class="nv">isRunning</span><span class="p">:</span> <span class="kt">Bool</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell19PrintedAsyncCommandC4stopyyF"></a>
<a name="//apple_ref/swift/Method/stop()" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell19PrintedAsyncCommandC4stopyyF">stop()</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Terminates the command by sending the SIGTERM signal.</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">stop</span><span class="p">()</span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell19PrintedAsyncCommandC9interruptyyF"></a>
<a name="//apple_ref/swift/Method/interrupt()" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell19PrintedAsyncCommandC9interruptyyF">interrupt()</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Interrupts the command by sending the SIGINT signal.</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">interrupt</span><span class="p">()</span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell19PrintedAsyncCommandC7suspendSbyF"></a>
<a name="//apple_ref/swift/Method/suspend()" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell19PrintedAsyncCommandC7suspendSbyF">suspend()</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Temporarily suspends a command. Call resume() to resume a suspended command.</p>
<div class="aside aside-warning">
<p class="aside-title">Warning</p>
You may suspend a command multiple times, but it must be resumed an equal number of times before the command will truly be resumed.
</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">@discardableResult</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="nf">suspend</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>
</div>
</div>
<div>
<h4>Return Value</h4>
<p><code>true</code> iff the command was successfully suspended.</p>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell19PrintedAsyncCommandC6resumeSbyF"></a>
<a name="//apple_ref/swift/Method/resume()" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell19PrintedAsyncCommandC6resumeSbyF">resume()</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Resumes a command previously suspended with suspend().</p>
<div class="aside aside-warning">
<p class="aside-title">Warning</p>
If the command has been suspended multiple times then it will have to be resumed the same number of times before execution will truly be resumed.
</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">@discardableResult</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="nf">resume</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>
</div>
</div>
<div>
<h4>Return Value</h4>
<p>true if the command was successfully resumed.</p>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell19PrintedAsyncCommandC6finishACXDyKF"></a>
<a name="//apple_ref/swift/Method/finish()" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell19PrintedAsyncCommandC6finishACXDyKF">finish()</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Waits for this command to finish.</p>
<div class="aside aside-warning">
<p class="aside-title">Warning</p>
Hangs if the unread output of either standard output or standard error is larger than 64KB (<a href="https://github.com/kareman/SwiftShell/issues/52">#52</a>). To work around this problem, read all the output first, even if you&rsquo;re not going to use it.
</div>
<div class="aside aside-throws">
<p class="aside-title">Throws</p>
<code>CommandError.returnedErrorCode(command: String, errorcode: Int)</code> if the exit 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">@discardableResult</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="nf">finish</span><span class="p">()</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="k">Self</span></code></pre>
</div>
</div>
<div>
<h4>Return Value</h4>
<p>self</p>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell19PrintedAsyncCommandC8exitcodeSiyF"></a>
<a name="//apple_ref/swift/Method/exitcode()" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell19PrintedAsyncCommandC8exitcodeSiyF">exitcode()</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Waits for command to finish, then returns with exit code.</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">exitcode</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Int</span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell19PrintedAsyncCommandC17terminationReasonSo017NSTaskTerminationG0VyF"></a>
<a name="//apple_ref/swift/Method/terminationReason()" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell19PrintedAsyncCommandC17terminationReasonSo017NSTaskTerminationG0VyF">terminationReason()</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Waits for the command to finish, then returns why the command terminated.</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">terminationReason</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Process</span><span class="o">.</span><span class="kt">TerminationReason</span></code></pre>
</div>
</div>
<div>
<h4>Return Value</h4>
<p><code>.exited</code> if the command exited normally, otherwise <code>.uncaughtSignal</code>.</p>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10SwiftShell19PrintedAsyncCommandC12onCompletionyACXDyACcF"></a>
<a name="//apple_ref/swift/Method/onCompletion(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:10SwiftShell19PrintedAsyncCommandC12onCompletionyACXDyACcF">onCompletion(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Takes a closure to be called when the command has 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">@discardableResult</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="nf">onCompletion</span><span class="p">(</span><span class="n">_</span> <span class="nv">handler</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt">PrintedAsyncCommand</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="k">Self</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>handler</em>
</code>
</td>
<td>
<div>
<p>A closure taking this AsyncCommand as input, returning nothing.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<h4>Return Value</h4>
<p>This PrintedAsyncCommand.</p>
</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>