Updated documentation.

This commit is contained in:
Erik C. Thauvin 2021-10-16 00:54:50 -07:00
parent 4ee7ec2127
commit fd3661b21b
14 changed files with 441 additions and 125 deletions

View file

@ -53,8 +53,9 @@ dart compile exe bin/dcat.dart
```dart
import 'package:dcat/dcat.dart';
final result = await cat(['path/to/file', 'path/to/otherfile]'], File('path/to/outfile'));
if (result.exitCode == exitFailure) {
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");
}
@ -66,9 +67,8 @@ The `cat` function supports the following parameters:
Parameter | Description | Type
:--------------- |:----------------------------- | :-------------------
paths | The file paths. | String[]
output | The standard output or file. | IOSink or File
output | The standard output or file. | [IOSink](https://api.dart.dev/dart-io/IOSink-class.html)
input | The standard input. | Stream<List\<int\>\>?
log | The log for debugging. | List\<String\>?
showEnds | Same as `-e` | bool
numberNonBlank | Same as `-b` | bool
showLineNumbers | Same as `-n` | bool
@ -77,9 +77,8 @@ squeezeBlank | Same as `-s` | bool
showNonPrinting | Same as `-v` | bool
* `paths` and `output` are required.
* `output` should be an `IOSink` like `stdout` or a `File`.
* `input` can be `stdin`.
* `log` is used for debugging/testing purposes.
* `output` should be an [IOSink](https://api.dart.dev/dart-io/IOSink-class.html) like `stdout` or a [File](https://api.dart.dev/dart-io/File/openWrite.html) stream.
* `input` can be [stdin](https://api.dart.dev/dart-io/Stdin-class.html).
The remaining optional parameters are similar to the [GNU cat](https://www.gnu.org/software/coreutils/manual/html_node/cat-invocation.html#cat-invocation) utility.
@ -89,11 +88,13 @@ A `CatResult` object is returned which contains the `exitCode` (`exitSuccess` or
final result = await cat(['path/to/file'], stdout);
if (result.exitCode == exitSuccess) {
...
} else {
for (final message in result.messages) {
stderr.writeln("Error: $message");
}
}
```
## Differences from [GNU cat](https://www.gnu.org/software/coreutils/manual/html_node/cat-invocation.html#cat-invocation)
- No binary file support.
- A line is considered terminated by either a `CR` (carriage return), a `LF` (line feed), a `CR+LF` sequence (DOS line ending).
- A line ending is automatically appended to the last line of any read file.
- The `U+` notation is used instead of `M-` for non-printing characters.
- The [U+](https://en.wikipedia.org/wiki/Unicode) notation is used instead of `M-` for non-printing characters.