read static method

Future<Blueprint> read(
  1. String path
)

Parses the blueprint at path.

The extension decides the format; content is never sniffed. A sniffed format is one that changes when somebody adds a comment, and the whole point of fixing it at authoring time is that it does not move.

Implementation

static Future<Blueprint> read(String path) async {
  final file = File(path);
  if (!await file.exists()) {
    throw CliError('blueprint file not found: $path');
  }

  try {
    return parseBlueprint(
      await file.readAsString(),
      formatOf(path),
      origin: path,
    );
  } on ProtocolException catch (e) {
    // A malformed file is the operator's problem with *their* file, not a
    // protocol failure to be rendered with a stack trace.
    throw CliError(e.message);
  }
}