AvailableToolsets returns the unique toolsets that have tools, in sorted order. This is the ordered intersection of toolsets with reality - only toolsets that actually contain tools are returned, sorted by toolset ID. Optional exclude parameter filters out specific toolset IDs from the result.
(exclude ...ToolsetID)
| 315 | // actually contain tools are returned, sorted by toolset ID. |
| 316 | // Optional exclude parameter filters out specific toolset IDs from the result. |
| 317 | func (r *Inventory) AvailableToolsets(exclude ...ToolsetID) []ToolsetMetadata { |
| 318 | tools := r.AllTools() |
| 319 | if len(tools) == 0 { |
| 320 | return nil |
| 321 | } |
| 322 | |
| 323 | // Build exclude set for O(1) lookup |
| 324 | excludeSet := make(map[ToolsetID]bool, len(exclude)) |
| 325 | for _, id := range exclude { |
| 326 | excludeSet[id] = true |
| 327 | } |
| 328 | |
| 329 | var result []ToolsetMetadata |
| 330 | var lastID ToolsetID |
| 331 | for _, tool := range tools { |
| 332 | if tool.Toolset.ID != lastID { |
| 333 | lastID = tool.Toolset.ID |
| 334 | if !excludeSet[lastID] { |
| 335 | result = append(result, tool.Toolset) |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | return result |
| 340 | } |
| 341 | |
| 342 | // EnabledToolsets returns the unique toolsets that are enabled based on current filters. |
| 343 | // This is similar to AvailableToolsets but respects the enabledToolsets filter. |