validateTargetDirectories method

void validateTargetDirectories()

Implementation

void validateTargetDirectories() {
  final rest = argResults?.rest ?? [];
  if (rest.isEmpty) {
    const _exceptionMessage =
        'Invalid number of directories. At least one must be specified.';

    throw const InvalidArgumentException(_exceptionMessage);
  }

  final rootFolderPath = argResults?[rootFolder] as String;
  for (final relativePath in rest) {
    final absolutePath = join(rootFolderPath, relativePath);
    if (!Directory(absolutePath).existsSync()) {
      final _exceptionMessage =
          "$absolutePath doesn't exist or isn't a directory.";

      throw InvalidArgumentException(_exceptionMessage);
    }
  }
}