176 lines
8.3 KiB
HTML
176 lines
8.3 KiB
HTML
<!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, height=device-height, initial-scale=1, user-scalable=no">
|
|
<meta name="generator" content="made with love by dartdoc 4.0.0">
|
|
<meta name="description" content="dcat API docs, for the Dart programming language.">
|
|
<title>dcat - Dart API docs</title>
|
|
|
|
|
|
|
|
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap" rel="stylesheet">
|
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
|
|
|
<link rel="stylesheet" href="static-assets/github.css?v1">
|
|
<link rel="stylesheet" href="static-assets/styles.css?v1">
|
|
<link rel="icon" href="static-assets/favicon.png?v1">
|
|
|
|
|
|
</head>
|
|
|
|
|
|
<body data-base-href=""
|
|
data-using-base-href="false">
|
|
|
|
<div id="overlay-under-drawer"></div>
|
|
|
|
<header id="title">
|
|
<button id="sidenav-left-toggle" type="button"> </button>
|
|
<ol class="breadcrumbs gt-separated dark hidden-xs">
|
|
<li><a href="https://github.com/ethauvin/dcat">dcat package</a></li>
|
|
</ol>
|
|
<div class="self-name">dcat</div>
|
|
<form class="search navbar-right" role="search">
|
|
<input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
|
|
</form>
|
|
</header>
|
|
|
|
<main>
|
|
|
|
|
|
<div id="dartdoc-main-content" class="main-content">
|
|
|
|
<section class="desc markdown">
|
|
<p><a href="http://opensource.org/licenses/BSD-3-Clause"><img src="https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square" alt="License (3-Clause BSD)"></a>
|
|
<a href="https://github.com/ethauvin/dcat/actions/workflows/dart.yml"><img src="https://github.com/ethauvin/dcat/actions/workflows/dart.yml/badge.svg" alt="GitHub CI"></a>
|
|
<a href="https://codecov.io/gh/ethauvin/dcat"><img src="https://codecov.io/gh/ethauvin/dcat/branch/master/graph/badge.svg?token=9PC4K4IZXJ" alt="codecov"></a></p>
|
|
<h1 id="dcat-concatenate-files-to-standard-output-or-file">dcat: Concatenate File(s) to Standard Output or File</h1>
|
|
<p>A <strong>cat</strong> command-line and library implementation in <a href="https://dart.dev/">Dart</a>, inspired by the <a href="https://dart.dev/tutorials/server/cmdline">Write command-line apps sample code</a>.</p>
|
|
<h2 id="synopsis">Synopsis</h2>
|
|
<p><strong>dcat</strong> copies each file, or standard input if none are given, to standard output or file.</p>
|
|
<h2 id="command-line-usage">Command-Line Usage</h2>
|
|
<pre class="language-sh"><code class="language-sh">dcat --help
|
|
</code></pre>
|
|
<pre class="language-dart"><code>Usage: dcat [OPTION]... [FILE]...
|
|
Concatenate FILE(s) to standard output.
|
|
|
|
With no FILE, or when FILE is -, read standard input.
|
|
|
|
-A, --show-all equivalent to -vET
|
|
-b, --number-nonblank number nonempty output lines, overrides -n
|
|
-e, --show-nonprinting-ends equivalent to -vE
|
|
-E, --show-ends display $ at end of each line
|
|
-h, --help display this help and exit
|
|
-n, --number number all output lines
|
|
-t, --show-nonprinting-tabs equivalent to -vT
|
|
-T, --show-tabs display TAB characters as ^I
|
|
-s, --squeeze-blank suppress repeated empty output lines
|
|
--version output version information and exit
|
|
-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
|
|
|
|
Examples:
|
|
dcat f - g Output f's contents, then standard input, then g's contents.
|
|
dcat Copy standard input to standard output.
|
|
</code></pre>
|
|
<h2 id="compile-standalone-application">Compile Standalone Application</h2>
|
|
<h3 id="nix">*nix</h3>
|
|
<pre class="language-sh"><code class="language-sh">dart compile exe -o bin/dcat bin/dcat.dart
|
|
</code></pre>
|
|
<h3 id="windows">Windows</h3>
|
|
<pre class="language-cmd"><code class="language-cmd">dart compile exe bin/dcat.dart
|
|
</code></pre>
|
|
<h2 id="library-usage">Library Usage</h2>
|
|
<pre class="language-dart"><code class="language-dart">import 'package:dcat/dcat.dart';
|
|
|
|
final result = await cat(['path/to/file', 'path/to/otherfile]'],
|
|
File('path/to/outfile').openWrite());
|
|
if (result.isFailure) {
|
|
for (final message in result.messages) {
|
|
print("Error: $message");
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p>The <code>cat</code> function supports the following parameters:</p>
|
|
<table><thead><tr><th style="text-align: left;">Parameter</th><th style="text-align: left;">Description</th><th style="text-align: left;">Type</th></tr></thead><tbody><tr><td style="text-align: left;">paths</td><td style="text-align: left;">The file paths.</td><td style="text-align: left;">String[]</td></tr><tr><td style="text-align: left;">output</td><td style="text-align: left;">The standard output or file.</td><td style="text-align: left;"><a href="https://api.dart.dev/dart-io/IOSink-class.html">IOSink</a></td></tr><tr><td style="text-align: left;">input</td><td style="text-align: left;">The standard input.</td><td style="text-align: left;"><a href="https://api.dart.dev/dart-io/Stdin-class.html">Stream</a></td></tr><tr><td style="text-align: left;">showEnds</td><td style="text-align: left;">Same as <code>-e</code></td><td style="text-align: left;">bool</td></tr><tr><td style="text-align: left;">numberNonBlank</td><td style="text-align: left;">Same as <code>-b</code></td><td style="text-align: left;">bool</td></tr><tr><td style="text-align: left;">showLineNumbers</td><td style="text-align: left;">Same as <code>-n</code></td><td style="text-align: left;">bool</td></tr><tr><td style="text-align: left;">showTabs</td><td style="text-align: left;">Same as <code>-T</code></td><td style="text-align: left;">bool</td></tr><tr><td style="text-align: left;">squeezeBlank</td><td style="text-align: left;">Same as <code>-s</code></td><td style="text-align: left;">bool</td></tr><tr><td style="text-align: left;">showNonPrinting</td><td style="text-align: left;">Same as <code>-v</code></td><td style="text-align: left;">bool</td></tr></tbody></table>
|
|
<ul>
|
|
<li><code>paths</code> and <code>output</code> are required.</li>
|
|
<li><code>output</code> should be an <a href="https://api.dart.dev/dart-io/IOSink-class.html">IOSink</a> such as <code>stdout</code> or a <a href="https://api.dart.dev/dart-io/File/openWrite.html">File</a> stream.</li>
|
|
<li><code>input</code> can be <a href="https://api.dart.dev/dart-io/Stdin-class.html">stdin</a>.</li>
|
|
</ul>
|
|
<p>The remaining optional parameters are similar to the <a href="https://www.gnu.org/software/coreutils/manual/html_node/cat-invocation.html#cat-invocation">GNU cat</a> utility.</p>
|
|
<p>A <code>CatResult</code> object is returned which contains the <code>exitCode</code> (<code>exitSuccess</code> or <code>exitFailure</code>) and error <code>messages</code> if any:</p>
|
|
<pre class="language-dart"><code class="language-dart">final result = await cat(['path/to/file'], stdout);
|
|
if (result.exitCode == exitSuccess) {
|
|
...
|
|
} else {
|
|
for (final message in result.messages) {
|
|
stderr.writeln("Error: $message");
|
|
}
|
|
}
|
|
</code></pre>
|
|
</section>
|
|
|
|
|
|
<section class="summary">
|
|
<h2>Libraries</h2>
|
|
<dl>
|
|
<dt id="dcat">
|
|
<span class="name"><a href="dcat/dcat-library.html">dcat</a></span>
|
|
|
|
</dt>
|
|
<dd>A library to concatenate files to standard output or file.
|
|
</dd>
|
|
|
|
</dl>
|
|
</section>
|
|
|
|
</div> <!-- /.main-content -->
|
|
|
|
<div id="dartdoc-sidebar-left" class="sidebar sidebar-offcanvas-left">
|
|
<header id="header-search-sidebar" class="hidden-l">
|
|
<form class="search-sidebar" role="search">
|
|
<input type="text" id="search-sidebar" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
|
|
</form>
|
|
</header>
|
|
|
|
<ol class="breadcrumbs gt-separated dark hidden-l" id="sidebar-nav">
|
|
<li><a href="https://github.com/ethauvin/dcat">dcat package</a></li>
|
|
</ol>
|
|
|
|
|
|
<h5 class="hidden-xs"><span class="package-name">dcat</span> <span class="package-kind">package</span></h5>
|
|
<ol>
|
|
<li class="section-title">Libraries</li>
|
|
<li><a href="dcat/dcat-library.html">dcat</a></li>
|
|
</ol>
|
|
|
|
</div>
|
|
|
|
<div id="dartdoc-sidebar-right" class="sidebar sidebar-offcanvas-right">
|
|
</div>
|
|
|
|
</main>
|
|
|
|
<footer>
|
|
<span class="no-break">
|
|
dcat
|
|
1.0.0
|
|
</span>
|
|
|
|
|
|
</footer>
|
|
|
|
|
|
|
|
<script src="static-assets/highlight.pack.js?v1"></script>
|
|
<script src="static-assets/script.js?v1"></script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|