showCurrent method

Future<void> showCurrent(
  1. String? projectPath
)

Show current project for directory

Implementation

Future<void> showCurrent(String? projectPath) async {
  final absolutePath = (projectPath != null && projectPath != '.')
      ? path.absolute(projectPath)
      : Directory.current.path;

  final projectId = ProjectConfigManager.loadProjectId(absolutePath);
  final config = ConfigManager.loadConfig();

  print('📁 Directory: $absolutePath');
  print('');

  if (projectId != null) {
    print('✓ Project set for this directory:');
    print('  Project ID: $projectId');
    print(
        '  Config file: ${path.join(absolutePath, '.ulink', 'project.json')}');

    // Try to get project name from API if available
    if (config?.auth != null) {
      try {
        final apiClient = ULinkApiClient(
          baseUrl: baseUrl,
          apiKey: config!.auth!.apiKey,
        );
        final projects = await apiClient.getProjects();
        final project = projects.firstWhere(
          (p) => p.id == projectId,
          orElse: () => projects.first,
        );
        print('  Project Name: ${project.name}');
      } catch (e) {
        // Ignore errors when fetching project name
      }
    }
  } else {
    print('✗ No project set for this directory');
    print('  Run "ulink project set" to select a project for this directory');
  }
}