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

Function matchSkillByName

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

Source from the content-addressed store, hash-verified

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