Coverage for src/mafw/devtools/cli/toolchain/list_cmd.py: 100%
20 statements
« prev ^ index » next coverage.py v7.15.0, created at 2026-07-26 09:13 +0000
« prev ^ index » next coverage.py v7.15.0, created at 2026-07-26 09:13 +0000
1# Copyright 2026 European Union
2# Author: Bulgheroni Antonio (antonio.bulgheroni@ec.europa.eu)
3# SPDX-License-Identifier: EUPL-1.2
4"""
5The ``list`` subcommand for the toolchain CLI group.
7This module implements the ``devtools toolchain list`` command, which displays
8a Rich table of all applicable tools with their name and category. Tools are
9filtered by the group-level ``--include-host`` / ``--exclude-host`` flags and
10the subcommand-level ``-i`` / ``-e`` options, then displayed in their
11registered order.
12"""
14from __future__ import annotations
16import click
17from rich.table import Table
19from mafw.devtools.cli.toolchain._group import common_options, toolchain
20from mafw.devtools.toolchain.filtering import resolve_tools
21from mafw.tools.shell_tools import CONSOLE
24@toolchain.command(name='list')
25@common_options
26@click.pass_context
27def list_cmd(ctx: click.Context, include: tuple[str, ...], exclude: tuple[str, ...]) -> None:
28 """List all registered toolchain tools and their category."""
29 registry = ctx.obj['registry']
30 include_host: bool = ctx.obj['include_host']
32 tools = resolve_tools(registry, include=include, exclude=exclude, include_host=include_host)
34 # Build a Rich table with tool name and category columns.
35 table = Table(title='Toolchain Tools')
36 table.add_column('Tool', style='cyan', no_wrap=True)
37 table.add_column('Category', style='magenta')
39 for tool in tools:
40 table.add_row(tool.name, tool.category)
42 CONSOLE.print(table)
44 raise SystemExit(0)