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

Function updateRun

pkg/cmd/skills/update/update.go:143–405  ·  view source on GitHub ↗
(opts *UpdateOptions)

Source from the content-addressed store, hash-verified

141}
142
143func updateRun(opts *UpdateOptions) error {
144 cs := opts.IO.ColorScheme()
145 canPrompt := opts.IO.CanPrompt()
146
147 httpClient, err := opts.HttpClient()
148 if err != nil {
149 return err
150 }
151 apiClient := api.NewClientFromHTTP(httpClient)
152
153 gitRoot := installer.ResolveGitRoot(opts.GitClient)
154 homeDir := installer.ResolveHomeDir()
155
156 // Scan for installed skills
157 var installed []installedSkill
158 if opts.Dir != "" {
159 skills, scanErr := scanInstalledSkills(opts.Dir, nil, "")
160 if scanErr != nil {
161 return fmt.Errorf("could not scan directory: %w", scanErr)
162 }
163 installed = skills
164 } else {
165 installed = scanAllAgents(gitRoot, homeDir)
166 }
167
168 if len(installed) == 0 {
169 fmt.Fprintf(opts.IO.ErrOut, "No installed skills found.\n")
170 return nil
171 }
172
173 // Filter to requested skills if specified
174 if len(opts.Skills) > 0 {
175 requested := make(map[string]bool, len(opts.Skills))
176 for _, name := range opts.Skills {
177 requested[name] = true
178 }
179 var filtered []installedSkill
180 for _, s := range installed {
181 if requested[s.name] {
182 filtered = append(filtered, s)
183 }
184 }
185 if len(filtered) == 0 {
186 return fmt.Errorf("none of the specified skills are installed")
187 }
188 installed = filtered
189 }
190
191 // Skip skills with invalid metadata rather than aborting the entire
192 // update run. One corrupt skill should not prevent updating others.
193 {
194 var valid []installedSkill
195 for _, s := range installed {
196 if s.metadataErr != nil {
197 fmt.Fprintf(opts.IO.ErrOut, "%s Skipping %s: invalid repository metadata: %s\n", cs.WarningIcon(), s.name, s.metadataErr)
198 continue
199 }
200 valid = append(valid, s)

Callers 2

NewCmdUpdateFunction · 0.85
TestUpdateRunFunction · 0.85

Calls 15

NewClientFromHTTPFunction · 0.92
ResolveGitRootFunction · 0.92
ResolveHomeDirFunction · 0.92
ResolveRefFunction · 0.92
DiscoverSkillsFunction · 0.92
ShortSHAFunction · 0.92
ShortRefFunction · 0.92
scanAllAgentsFunction · 0.85
promptForSkillOriginFunction · 0.85
updateSkillInPlaceFunction · 0.85
ColorSchemeMethod · 0.80
CanPromptMethod · 0.80

Tested by 1

TestUpdateRunFunction · 0.68