MCPcopy Index your code
hub / github.com/nikivdev/go / workspacePathsCmd

Function workspacePathsCmd

workspace.go:269–333  ·  view source on GitHub ↗
(ctx *snap.Context)

Source from the content-addressed store, hash-verified

267}
268
269func workspacePathsCmd(ctx *snap.Context) error {
270 var args []string
271 for i := 0; i < ctx.NArgs(); i++ {
272 arg := strings.TrimSpace(ctx.Arg(i))
273 if arg != "" {
274 args = append(args, arg)
275 }
276 }
277
278 var workspacePathArg string
279 var cleanedArgs []string
280 for i := 0; i < len(args); i++ {
281 if args[i] == "--file" || args[i] == "-f" {
282 if i+1 >= len(args) {
283 return fmt.Errorf("missing value for %s", args[i])
284 }
285 workspacePathArg = args[i+1]
286 i++
287 continue
288 }
289 cleanedArgs = append(cleanedArgs, args[i])
290 }
291 args = cleanedArgs
292
293 listKind := workspaceListRepoPaths
294 if len(args) > 0 {
295 if parsed, ok := workspaceListFromArg(args[0]); ok {
296 listKind = parsed
297 args = args[1:]
298 }
299 }
300
301 action := "list"
302 if len(args) > 0 {
303 action = strings.ToLower(args[0])
304 args = args[1:]
305 }
306
307 var pathArg string
308 if len(args) > 0 {
309 pathArg = args[0]
310 }
311
312 workspaceFile, err := resolveWorkspaceFilePath(workspacePathArg)
313 if err != nil {
314 return err
315 }
316
317 doc, err := loadWorkspaceFile(workspaceFile)
318 if err != nil {
319 return fmt.Errorf("load workspace %s: %w", workspaceFile, err)
320 }
321
322 label := workspaceListLabels[listKind]
323 switch action {
324 case "list":
325 return workspaceListPaths(ctx.Stdout(), doc.list(listKind), label, workspaceFile)
326 case "add":

Callers 1

mainFunction · 0.85

Calls 7

workspaceListFromArgFunction · 0.70
resolveWorkspaceFilePathFunction · 0.70
loadWorkspaceFileFunction · 0.70
workspaceListPathsFunction · 0.70
workspaceAddPathFunction · 0.70
workspaceRemovePathFunction · 0.70
listMethod · 0.45

Tested by

no test coverage detected