mafw.devtools.toolchain.registry
Central registry for ToolChainTool instances.
The ToolRegistry maintains an ordered collection of all registered
development tools, enabling discovery and iteration by the CLI commands.
Tools are stored in insertion order and can be retrieved by name or filtered
by category.
Classes
Central registry that maintains all registered ToolChainTool instances. |
- class mafw.devtools.toolchain.registry.ToolRegistry[source]
Bases:
objectCentral registry that maintains all registered ToolChainTool instances.
Tools are stored in insertion order and indexed by name for O(1) lookup. Duplicate names are rejected to ensure each tool has a unique identifier within the registry.
Usage:
registry = ToolRegistry() registry.register(my_tool) all_tools = registry.all() project_tools = registry.filter_by_category('project') specific = registry.get('ruff')
- all() list[ToolChainTool][source]
Return all registered tools in insertion order.
- Returns:
A new list containing all tools in the order they were registered.
- Return type:
list[toolchain.ToolChainTool]
- filter_by_category(category: Literal['host', 'project']) list[ToolChainTool][source]
Return tools matching the given category, preserving insertion order.
- Parameters:
category – The category to filter by (
"host"or"project").- Returns:
A list of matching tools, or an empty list if none match.
- Return type:
list[toolchain.ToolChainTool]
- get(name: str) ToolChainTool[source]
Retrieve a tool by its exact name (case-sensitive).
- Parameters:
name – The tool name to look up.
- Returns:
The matching
toolchain.ToolChainToolinstance.- Return type:
- Raises:
KeyError – If no tool with the given name is registered.
- register(tool: ToolChainTool) None[source]
Add a tool to the registry.
The tool is appended to the internal list and indexed by name. If a tool with the same name already exists, a
ValueErroris raised and the registry state remains unchanged.- Parameters:
tool – The tool instance to register.
- Raises:
ValueError – If a tool with the same name is already registered.