MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / completeCollectionNames

Function completeCollectionNames

cmd/pad/cmd_collection.go:412–434  ·  view source on GitHub ↗

--- edit --- completeCollectionNames provides shell completion for collection names.

(cmd *cobra.Command, args []string, toComplete string)

Source from the content-addressed store, hash-verified

410
411// completeCollectionNames provides shell completion for collection names.
412func completeCollectionNames(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
413 if len(args) > 0 {
414 return nil, cobra.ShellCompDirectiveNoFileComp
415 }
416 // Static list of common collection names (singular + plural)
417 names := []string{"task", "tasks", "idea", "ideas", "plan", "plans", "doc", "docs", "bug", "bugs"}
418 // Try to fetch dynamic collections from API
419 cfg, err := config.Load()
420 if err == nil && cfg.IsConfigured() {
421 if cli.EnsureServer(cfg) == nil {
422 client := cli.NewClientFromURL(cfg.BaseURL())
423 if ws, err := cli.DetectWorkspace(workspaceFlag); err == nil {
424 if colls, err := client.ListCollections(ws); err == nil {
425 names = nil
426 for _, c := range colls {
427 names = append(names, c.Slug)
428 }
429 }
430 }
431 }
432 }
433 return names, cobra.ShellCompDirectiveNoFileComp
434}
435
436// printAvailableCollections fetches collections from the API and prints them
437// with their descriptions and valid status values. Used by create --help.

Callers

nothing calls this directly

Calls 7

LoadFunction · 0.92
EnsureServerFunction · 0.92
NewClientFromURLFunction · 0.92
DetectWorkspaceFunction · 0.92
IsConfiguredMethod · 0.80
BaseURLMethod · 0.45
ListCollectionsMethod · 0.45

Tested by

no test coverage detected