loadConfig method
Load configuration from file
Implementation
Future<TranslationConfig> loadConfig() async {
if (!configExists()) {
throw Exception(
'Configuration file not found. Run "aitranslation init" first.',
);
}
try {
final file = File(configFileName);
final content = await file.readAsString();
final yaml = loadYaml(content);
if (yaml is! Map) {
throw Exception('Invalid YAML format');
}
return TranslationConfig.fromMap(Map<String, dynamic>.from(yaml));
} catch (e) {
if (e is YamlException) {
throw Exception('Invalid YAML syntax: ${e.message}');
} else {
throw Exception('Failed to load configuration: ${e.toString()}');
}
}
}