run method

  1. @override
Future<void> run()
override

Run the command

Implementation

@override
Future<void> run() async {
  if (repo == null || repo!.isEmpty) {
    _showUsage();
    return;
  }

  // Validate repo format
  if (!_isValidRepoFormat(repo!)) {
    stderr.writeln('✗ Invalid repository format: $repo');
    stderr.writeln('Expected format: owner/repo');
    exit(1);
  }

  final fetcher = GitHubSkillFetcher(skillsPath: skillsPath);

  try {
    if (skillName == null || skillName!.isEmpty) {
      // List available skills
      await _listSkills(fetcher, repo!);
    } else {
      // Add specific skill
      await _addSkill(fetcher, repo!, skillName!);
    }
  } on SkillLoadException catch (e) {
    stderr.writeln('✗ ${e.message}');
    exit(1);
  } catch (e) {
    stderr.writeln('✗ Error: $e');
    exit(1);
  } finally {
    fetcher.close();
  }
}