Skip to content

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

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

Access command output

finalString out =awaitexec('cat', ['example/names.csv']).runGetOutput();
print(out);

or

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

Pipe

awaitexec('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']) >newUri(path:'example/dest.csv'))
.run();

Input redirection

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

Inline functions

awaitexec('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

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages