MCPcopy Index your code
hub / github.com/cli/cli / skillNameFromSourcePath

Function skillNameFromSourcePath

pkg/cmd/skills/list/list.go:460–489  ·  view source on GitHub ↗
(sourcePath string)

Source from the content-addressed store, hash-verified

458}
459
460func skillNameFromSourcePath(sourcePath string) string {
461 sourcePath = strings.TrimSuffix(sourcePath, "/SKILL.md")
462 sourcePath = strings.Trim(sourcePath, "/")
463 if sourcePath == "" {
464 return ""
465 }
466
467 parts := strings.Split(sourcePath, "/")
468 for i := len(parts) - 1; i >= 0; i-- {
469 if parts[i] != "skills" {
470 continue
471 }
472
473 if i >= 2 && parts[i-2] == "plugins" && i+1 < len(parts) {
474 return parts[i-1] + "/" + parts[len(parts)-1]
475 }
476
477 afterSkills := len(parts) - i - 1
478 switch afterSkills {
479 case 0:
480 return ""
481 case 1:
482 return parts[i+1]
483 default:
484 return parts[i+1] + "/" + parts[len(parts)-1]
485 }
486 }
487
488 return parts[len(parts)-1]
489}
490
491func sortListedSkills(skills []listedSkill) {
492 sort.Slice(skills, func(i, j int) bool {

Callers 1

parseInstalledSkillFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected