run method

Future<int> run()

Implementation

Future<int> run() async {
  if (args['help'] case true) {
    logger.write(_usage);
    return 0;
  }

  try {
    final success = await git.unsetHooksDir();
    if (!success) {
      return 1;
    }
  } catch (e) {
    logger
      ..err('Could not unset hooks path')
      ..detail(e.toString());
    return 1;
  }

  final hooksPath = managedHooksDir;
  if (hooksPath != null) {
    final hooksDir = fs.directory(hooksPath);
    if (hooksDir.existsSync()) {
      for (final entity in hooksDir.listSync()) {
        final name = fs.path.basename(entity.path);
        if (name == '.gitignore' || name == 'README.md') continue;
        entity.deleteSync(recursive: true);
      }
      logger.info(darkGray.wrap('Removed managed shims from hooks/_'));
    }
  }

  logger.info(green.wrap('Uninstalled hooksman hooks'));
  return 0;
}