cli_script
1.0.0, released 3 years ago by sass-lang.com
Write shell-like scripts in Dart with support for subprocesses, pipelining, and streams.
What it does
It provides a robust Dart API for writing command-line scripts that interact with subprocesses, execute pipeline commands, capture outputs, and parse arguments with shell-like ease. It leverages Dart streams, futures, and exceptions while maintaining the core virtues of shell scripting such as terseness and composability.
AI-written summary of version 1.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- Writing stand-alone CLI scripts and automation tasks in Dart instead of Bash or Python
- Pipelining multiple subprocesses and file streams together
Skip it when
- Building cross-platform graphical user interface applications where subprocesses are not needed
- Heavy web-based applications since it targets standalone scripting environments
Strengths
- Clean syntax for running subprocesses and command pipelines
- Automatic redirection and error handling mirroring shell behavior
- Integrates seamlessly with Dart's asynchronous streams and futures
Weaknesses
- Platform behavior for certain features like glob expansion may vary
- Requires careful handling of stream listening order to avoid runtime errors
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 10
import 'package:cli_script/cli_script.dart';
void main() {
wrapMain(() async {
await run('echo "Hello, world!"');
});
}Alternatives
Packages that do the same job and could replace cli_script.
Works with
Packages commonly used together with cli_script: ones it builds on, ones built on it, and its own family.
- stack_tracecli_script depends on itProvides parsing, inspection, and readable formatting of Dart stack traces.
- globcli_script depends on itA file and directory globbing library that supports Bash-style path matching and listing.
- asynccli_script depends on itUtility classes and helpers that extend Dart's async library.
- source_spancli_script depends on itStandard representation for source code locations, spans, and human-friendly error messages.
- string_scannercli_script depends on itA class for parsing strings using a sequence of patterns.
- charcodecli_script depends on itProvides named integer constants for ASCII and HTML character codes.
- tuplecli_script depends on itProvides immutable tuple classes for grouping values.
- cli_pkgSame familyGrinder tasks for releasing Dart CLI packages.