pub repository
mirror.p-hatan.irio
1.0.2Utilities for the Dart VM Runtime including support for ANSI colors, file copying, and standard exit code values.
Readme
Contains utilities for the Dart VM's dart:io.
Usage - io.dart
Files
isExecutable
Returns whether a provided file path is considered executable on the host operating system.
Processes
ExitCode
An enum-like class that contains known exit codes.
ProcessManager
A higher-level service for spawning and communicating with processes.
Use spawn to create a process with std[in|out|err] forwarded by default
Future<void> main() async {
final manager = ProcessManager();
// Print `dart` tool version to stdout.
print('** Running `dart --version`');
var spawn = await manager.spawn('dart', ['--version']);
await spawn.exitCode;
// Check formatting and print the result to stdout.
print('** Running `dart format --output=none .`');
spawn = await manager.spawn('dart', ['format', '--output=none', '.']);
await spawn.exitCode;
// Check if a package is ready for publishing.
// Upon hitting a blocking stdin state, you may directly
// output to the processes's stdin via your own, similar to how a bash or
// shell script would spawn a process.
print('** Running pub publish');
spawn = await manager.spawn('dart', ['pub', 'publish', '--dry-run']);
await spawn.exitCode;
// Closes stdin for the entire program.
await sharedStdIn.terminate();
}
sharedStdIn
A safer version of the default stdin stream from dart:io that allows a
subscriber to cancel their subscription, and then allows a new subscriber to
start listening. This differs from the default behavior where only a single
listener is ever allowed in the application lifecycle:
test('should allow multiple subscribers', () async {
final logs = <String>[];
final asUtf8 = sharedStdIn.transform(UTF8.decoder);
// Wait for input for the user.
logs.add(await asUtf8.first);
// Wait for more input for the user.
logs.add(await asUtf8.first);
expect(logs, ['Hello World', 'Goodbye World']);
});
For testing, an instance of SharedStdIn may be created directly.
Usage - ansi.dart
import 'dart:io' as io;
import 'package:io/ansi.dart';
void main() {
// To use one style, call the `wrap` method on one of the provided top-level
// values.
io.stderr.writeln(red.wrap("Bad error!"));
// To use multiple styles, call `wrapWith`.
print(wrapWith('** Important **', [red, styleBold, styleUnderlined]));
// The wrap functions will simply return the provided value unchanged if
// `ansiOutputEnabled` is false.
//
// You can override the value `ansiOutputEnabled` by wrapping code in
// `overrideAnsiOutput`.
overrideAnsiOutput(false, () {
assert('Normal text' == green.wrap('Normal text'));
});
}
Changelog
1.0.2
-
- Update
metaconstraint to>=1.3.0 <3.0.0.
- Update
1.0.1
- Update code examples to call the unified
dartdeveloper tool.
1.0.0
- Migrate this package to null-safety
- Require Dart >=2.12
0.3.5
- Require Dart >=2.1
- Remove dependency on
package:charcode.
0.3.4
- Fix a number of issues affecting the package score on
pub.dev.
0.3.3
-
Updates for Dart 2 constants. Require at least Dart
2.0.0-dev.54. -
Fix the type of
StartProcesstypedef to matchProcess.startfromdart:io.
0.3.2+1
-
ansi.dart- The "forScript" code paths now ignore the
ansiOutputEnabledvalue. Affects theescapeForScriptproperty onAnsiCodeand thewrapandwrapWithfunctions whenforScriptis true.
- The "forScript" code paths now ignore the
0.3.2
-
ansi.dart-
Added
forScriptnamed argument to top-levelwrapWithfunction. -
AnsiCode-
Added
String get escapeForScriptproperty. -
Added
forScriptnamed argument towrapfunction.
-
-
0.3.1
- Added
SharedStdIn.nextLine(similar toreadLineSync) andlines:
main() async {
// Prints the first line entered on stdin.
print(await sharedStdIn.nextLine());
// Prints all remaining lines.
await for (final line in sharedStdIn.lines) {
print(line);
}
}
-
Added a
copyPathandcopyPathSyncfunction, similar tocp -R. -
Added a dependency on
package:path. -
Added the remaining missing arguments to
ProcessManager.spawnXwhich forward toProcess.start. It is now an interchangeable function for running a process.
0.3.0
- BREAKING CHANGE: The
argumentsargument toProcessManager.spawnis now positional (not named) and required. This makes it more similar to the built-inProcess.start, and easier to use as a drop in replacement:
main() {
processManager.spawn('dart', ['--version']);
}
-
Fixed a bug where processes created from
ProcessManager.spawncould not have theirstdout/stderrread through their respective getters (a runtime error was always thrown). -
Added
ProcessMangaer#spawnBackground, which does not forwardstdin. -
Added
ProcessManager#spawnDetached, which does not forward any I/O. -
Added the
shellSplit()function, which parses a list of arguments in the same manner as the POSIX shell.
0.2.0
- Initial commit of...
FutureOr<bool> String isExecutable(path).ExitCodeProcessManagerandSpawnsharedStdInandSharedStdInansi.dartlibrary with support for formatting terminal output
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add iopubspec.yaml
name: io
description: >-
Utilities for the Dart VM Runtime including support for ANSI colors,
file copying, and standard exit code values.
version: 1.0.2
repository: https://github.com/dart-lang/io
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
meta: '>=1.3.0 <3.0.0'
path: ^1.8.0
string_scanner: ^1.1.0
dev_dependencies:
lints: ^1.0.0
test: ^1.16.0
test_descriptor: ^2.0.0
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.1.0-git | 2014-01-31T16:10:59.148830Z | Download | fd6aa308fe299d09bf8e74b904263f63b7edf9ac8da93a8cd4858e89cde8efa3 |
| 0.2.0 | 2017-08-15T17:10:25.884227Z | Download | 44bb445d895a73f61153049267ffa213a7862a8ee740e0cad2cb31f684e4d0f5 |
| 0.3.0 | 2017-10-12T04:32:28.258Z | Download | 5345fffe9fd4d236b1d34e39d03df62e3a68ec31fb470b77d8d1448a95004599 |
| 0.3.1 | 2017-12-01T21:15:39.731331Z | Download | 1f3d7c8bd50e8c2be52b75613d3efcda9d270350d4b58f0ad5f6e44c728e14b7 |
| 0.3.2 | 2018-01-30T23:32:02.719943Z | Download | 00073236d20de7ab837bdbb50ff35570dd77b3923ffd0d4aef755877fed1446c |
| 0.3.2+1 | 2018-01-31T18:45:24.703422Z | Download | afc155bdced987c61cde283722e1561ad03be90740f1326cef7ffd9cd14310a3 |
| 0.3.3 | 2018-07-12T19:26:48.356685Z | Download | ea4d347b41c9fb92e2cfc6ea987fff30c122c90675f7bbfab86e92c3761d5168 |
| 0.3.4 | 2020-04-03T20:45:23.709663Z | Download | 69955598ee18b1044fc2e5199a146ea871f59561d5fdda5bdf4cc80644d81a04 |
| 0.3.5 | 2021-02-24T18:34:49.536151Z | Download | 9148a33dc8fa396d4fc434625fa606744fa42b2e8dfff5ce5609938cd01aecea |
| 1.0.0 | 2021-02-25T17:00:59.881409Z | Download | 15a5436d2a02dc60e6dc2fb5d7dfaac08b7b137cff3d4bf3158d38ecab656b69 |
| 1.0.2 | 2021-07-04T22:14:25.483705Z | Download | f2aaffe700540920b889f56f1d74db58a6a0269df5207a7b8f4fb78c71c6244a |
| 1.0.3 | 2021-07-07T18:14:00.760001Z | Download | 0d4c73c3653ab85bf696d51a9657604c900a370549196a91f33e4c39af760852 |
| 1.0.4 | 2023-01-19T21:51:23.745664Z | Download | 2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e |
| 1.0.5 | 2024-12-10T12:22:29.241911Z | Download | dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b |
| 1.1.0 | 2026-08-28T20:42:26.818695Z | Download | 2635216ca6a737e60de577ffa1a48a0bec76ca8a62917cfc1bb88c14c570646f |
Dependencies
meta "\u003e=1.3.0 \u003c3.0.0"
path "^1.8.0"
string_scanner "^1.1.0"