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

Function matchSkillByName

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

Source from the content-addressed store, hash-verified

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