runInteractive function
Runs a cmd with args in interactive mode.
Uses ProcessStartMode.inheritStdio to allow the user to interact directly with the subprocess (e.g. for login prompts).
Implementation
Future<void> runInteractive(String cmd, List<String> args) async {
print('š Running interactive: $cmd ${args.join(" ")}\n');
final env = getInjectedEnvironment();
try {
final process = await Process.start(
cmd,
args,
runInShell: true,
environment: env,
mode: ProcessStartMode.inheritStdio,
);
final exitCode = await process.exitCode;
if (exitCode != 0) {
throw Exception('$cmd failed with exit code $exitCode');
}
print('\nā
$cmd completed\n');
} catch (e) {
print('\nā Error while running interactive $cmd');
rethrow;
}
}