watch method

Future<int> watch()

For CLI Watches and organizes image files based on the settings in the configuration.

Returns the exit code of the operation.

Implementation

Future<int> watch() async {
  const int exitCode = 0;

  run();
  print('Watching...');

  final watcher = DirectoryWatcher(p.absolute(config.assetFolderPath));
  await for (var event in watcher.events) {
    if (event.type == ChangeType.ADD ||
        event.type == ChangeType.MODIFY ||
        event.type == ChangeType.REMOVE) {
      final f = File(event.path);
      print(f.toString());
      if (_matchWithFileExtensions(f)) {
        run();
      }
    }
  }

  return exitCode;
}