dscript_exec 2.0.1

  • Readme
  • Changelog
  • Installing
  • 65

Exec #

Bash like command piping and redirecting for Dart to make writing Dart scripts easier.

Say good-bye to bash, python and batch file scripting! Invest in a sound language with amazing analyzer tools!

From the authors of Jaguar.dart.

Usage #

Execute a command #

await exec('rm', ['example/dest.csv']).run();

Access command output #

final String out = await exec('cat', ['example/names.csv']).runGetOutput();
print(out);

or

await exec('cat', ['example/names.csv']).runGetOutput(onFinish: print);

Pipe #

await exec('cat', ['example/names.csv'])
  .pipe(exec('cut', ['-d', "','", '-f', '1']))
  .runGetOutput(onFinish: print);

Output redirection #

await (exec('cat', ['example/names.csv']) |
          exec('cut', ['-d', "','", '-f', '1']) >
      new Uri(path: 'example/dest.csv'))
  .run();

Input redirection #

await (exec('cut', ['-d', "','", '-f', '1']) <
      '''
John,Smith,34,London
Arthur,Evans,21,Newport
George,Jones,32,Truro
      ''')
  .runGetOutput(onFinish: print);

Inline functions #

await exec('cat', ['example/names.csv'])
  .pipeInlineLine(
      (Stream<String> stream) => stream.map((s) => s.split(',')[1]))
  .runGetOutput(onFinish: print);

TODO #

  • [ ] Catch and report error in sub-commands
  • [ ] Support other encoders
  • [ ] Support stderr redirection
  • [ ] Test multiple redirections
  • [ ] Support &, | and ~ concepts

Changelog #

1.0.0 #

  • Pipes
  • Output redirection
  • Input redirection
  • Inline commands

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dscript_exec: ^2.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dscript_exec/dscript_exec.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
31
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Oct 24, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:dscript_exec/dscript_exec.dart with components: io.

Health suggestions

Fix lib/exec/subcmd.dart. (-1.99 points)

Analysis of lib/exec/subcmd.dart reported 4 hints:

line 91 col 7: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 97 col 7: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 139 col 7: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 142 col 7: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

Maintenance suggestions

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and dscript_exec.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0