(opts *InstallOptions, skills []discovery.Skill)
| 796 | } |
| 797 | |
| 798 | func 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 | |
| 829 | func matchLocalSkillByName(opts *InstallOptions, skills []discovery.Skill) ([]discovery.Skill, error) { |
| 830 | for _, s := range skills { |
nothing calls this directly
no test coverage detected