main function

void main(
  1. List<String> args
)

Implementation

void main(List<String> args) async {
  final cmd = DocComparatorCommand();
  final argResults = cmd.argResults ?? cmd.argParser.parse(args);
  if (argResults['help'] as bool) {
    print(cmd.usage);
    return;
  }

  final magArg = argResults['magnitude'] as String;
  final magnitude = ApiChangeMagnitude.values
      .firstWhereOrNull((element) => element.toString().contains(magArg));

  final baseFile = argResults['base'] as String;
  final newFile = argResults['new'] as String;
  final newContent = await _getFileContent(newFile);
  final baseContent = await _getFileContent(baseFile);

  final apiChanges = parseDocComponentsFile(baseContent).compareTo(
    parseDocComponentsFile(newContent),
  );
  print(ApiChangeFormatter(apiChanges, showUpToMagnitude: magnitude).format());
}