run method

  1. @override
Future<int> run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
Future<int> run() async {
  await buildOpenapiDocumentProgress(logger, CancellationToken());
  var specs = await getPathFromRoot(path.join(".reedmace", "api_specs.json"))
      .readAsString();

  // Prettify JSON
  JsonEncoder encoder = JsonEncoder.withIndent("  ");
  specs = encoder.convert(json.decode(specs));

  await File(argResults!["output"]!).writeAsString(specs);
  logger
      .success("OpenAPI documentation written to ${argResults!["output"]!}");
  return 0;
}