read method

FlaiConfig read()

Reads and parses the config file.

Throws a FileSystemException if the file does not exist.

Implementation

FlaiConfig read() {
  final file = File(configPath);
  if (!file.existsSync()) {
    throw FileSystemException(
      'Config file not found. Run "flai init" first.',
      configPath,
    );
  }
  final content = file.readAsStringSync();
  final yaml = loadYaml(content);
  if (yaml is! Map) {
    throw FormatException('Invalid flai.yaml: expected a YAML mapping.');
  }
  return FlaiConfig.fromYaml(yaml);
}