run method
Run in headless mode with the given configuration.
Implementation
Future<HeadlessResult> run(HeadlessConfig config) async {
final stopwatch = Stopwatch()..start();
// Read input.
final inputText = switch (config.input) {
StdinInput() => await _readStdin(),
FileInput(path: final p) => await File(p).readAsString(),
StringInput(text: final t) => t,
};
if (inputText.isEmpty) {
return const HeadlessResult(
output: '',
success: false,
error: 'Empty input',
);
}
// In a real implementation, this sends the input to the API
// and collects the response.
stopwatch.stop();
return HeadlessResult(output: '', duration: stopwatch.elapsed);
}