Skip to content
pubscout

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.

$ flutter pub add cli_script
Source repository

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.

  • dcli

    A Dart SDK for building cross‑platform command line applications and scripts.

Works with

Packages commonly used together with cli_script: ones it builds on, ones built on it, and its own family.