run method

dynamic run()

Implementation

run(){
  pen.green("|------------------👋 Starting Auto Local Tool 👋----------------------------|");
  pen.green("|                   This Tool Built by Github: abom-me                                 |");
pen.yellow("""
This tool is used to generate a dart class from a JSON file.
the json file path should be in assets/lang/ directory.
because this tool is depend on flutter_locales2 package.
""");
  final String directoryPath = 'assets/lang/';
  final directory = Directory(directoryPath);

  if (directory.existsSync()) {
    _generateLocalizationClasses(); // Initial generation

    // Watch for changes in the directory
    final watcher = DirectoryWatcher(directoryPath);
    watcher.events.listen((event) {
      if (event.type == ChangeType.MODIFY) {

        _updateDartClass(event.path);
      }
    });

    pen.magenta("|------------------Waiting new data in $directoryPath---------------------|");

    // // Keep the process running
    // stdin.readLineSync();
  } else {
    pen.red('Directory not found: $directoryPath');
  }
}