autoDiscoverCommands method

Future<void> autoDiscoverCommands(
  1. String projectPath
)

Auto-discover and register custom commands from the user's project using mirrors.

Implementation

Future<void> autoDiscoverCommands(String projectPath) async {
  try {
    await _loadPackageName();

    final commandsDir = Directory(path.join(projectPath, 'app', 'commands'));
    if (!await commandsDir.exists()) {
      return;
    }

    final commandFiles = await _findCommandFiles(commandsDir);
    for (final file in commandFiles) {
      // Try mirror-based loading
      await _tryLoadCommandWithMirrors(file);
    }
  } catch (e) {
    logger.warning('Failed to auto-discover commands: $e');
  }
}