MCPcopy Create free account
hub / github.com/cli/cli / matchSkillByName

Function matchSkillByName

pkg/cmd/skills/install/install.go:796–825  ·  view source on GitHub ↗
(opts *InstallOptions, skills []discovery.Skill)

Source from the content-addressed store, hash-verified

794}
795
796func matchSkillByName(opts *InstallOptions, skills []discovery.Skill) ([]discovery.Skill, error) {
797 for _, s := range skills {
798 if s.DisplayName() == opts.SkillName {
799 return []discovery.Skill{s}, nil
800 }
801 }
802
803 var matches []discovery.Skill
804 for _, s := range skills {
805 if s.Name == opts.SkillName {
806 matches = append(matches, s)
807 }
808 }
809
810 switch len(matches) {
811 case 0:
812 return nil, fmt.Errorf("skill %q not found in %s", opts.SkillName, ghrepo.FullName(opts.repo))
813 case 1:
814 return matches, nil
815 default:
816 names := make([]string, len(matches))
817 for i, m := range matches {
818 names[i] = m.DisplayName()
819 }
820 return nil, fmt.Errorf(
821 "skill name %q is ambiguous, multiple matches found:\n %s\n Specify the full name (e.g. %s) to disambiguate",
822 opts.SkillName, strings.Join(names, "\n "), names[0],
823 )
824 }
825}
826
827func matchLocalSkillByName(opts *InstallOptions, skills []discovery.Skill) ([]discovery.Skill, error) {
828 for _, s := range skills {

Callers

nothing calls this directly

Calls 4

FullNameFunction · 0.92
JoinMethod · 0.80
DisplayNameMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected