run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
Future<void> run() async {
final configPath = argResults!['config'] as String;
final file = File(configPath);
if (!file.existsSync()) {
stderr.writeln('Config file not found: $configPath');
exit(1);
}
final yaml = loadYaml(file.readAsStringSync()) as Map;
final config = BlueprintConfig.fromYaml(yaml);
final targetDir = argResults!['output'] as String? ?? config.outputDir;
await Directory(targetDir).create(recursive: true);
final planItems = <PlanItemMessage>[];
final bridge = EngineBridge(onMessage: (msg) {
if (msg is PlanItemMessage) planItems.add(msg);
if (msg is LogMessage && msg.level == 'error') {
stderr.writeln(' error: ${msg.message}');
}
});
try {
await bridge.run(config, targetDir, dryRun: true);
} catch (e) {
stderr.writeln('Engine error: $e');
exit(1);
}
print('\nPlanned actions for "${config.name}":');
displayPlan(planItems);
}