--- edit --- completeCollectionNames provides shell completion for collection names.
(cmd *cobra.Command, args []string, toComplete string)
| 410 | |
| 411 | // completeCollectionNames provides shell completion for collection names. |
| 412 | func 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. |
nothing calls this directly
no test coverage detected