writeCompletionOutput function
Future<void>
writeCompletionOutput(
- CommandRunner<
OptionDefinition, dynamic> runner, - String output
Writes the completion output (a response or a script) to
CompletionSettings.sinks.
The usage output sinks are not used. They are for help text, and may reformat what they write.
If CompletionSettings.exitAfterResponse is set, the output is then
flushed and the process exits with exit code 0, so that nothing the
program does after CommandRunner.run() can corrupt the output.
Implementation
Future<void> writeCompletionOutput(
final CommandRunner runner,
final String output,
) async {
final sink = runner.completion.sinks.out;
sink.write(output);
if (!runner.completion.exitAfterResponse) return;
if (sink is IOSink) await sink.flush();
exit(0);
}