Skip to content

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

License

Notifications You must be signed in to change notification settings

desktop-dart/dscript_exec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages