start method
Implementation
Future<int> start({
String? workingDirectory,
void Function(String line)? progressOut,
void Function(String line)? progressErr,
bool showLog = true,
}) async {
final commandCli = CommandlineConverter().convert(this);
final executable = commandCli.first;
final arguments = commandCli.sublist(1);
final process = await Process.start(
executable,
arguments,
runInShell: true,
workingDirectory: workingDirectory,
environment: Platform.environment,
);
process.stdout.transform(utf8.decoder).listen(((line) {
progressOut?.call(line);
if (showLog) printMessage(line.replaceAll(RegExp(r'[\s\n]+$'), ''));
}));
process.stderr.transform(utf8.decoder).listen(((line) {
progressErr?.call(line);
if (showLog) printerrMessage(line.replaceAll(RegExp(r'[\s\n]+$'), ''));
}));
final exitCode = await process.exitCode;
if (exitCode > 0) {
throw Exception('$this has exit with code $exitCode');
}
return exitCode;
}