Show available SGN elements or information about a plugin or element.
Source code in src/sgn_inspect/cli.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 | @app.command()
def show(
name: Annotated[
str | None,
Argument(
metavar="[ELEMENT | PLUGIN]",
help="If specified, an element or plugin name. Otherwise list all elements",
),
] = None,
) -> None:
"""Show available SGN elements or information about a plugin or element."""
elements = discover_elements()
if name:
elements_by_plugin: dict[str, dict[str, ElementInfo]] = defaultdict(dict)
for info in elements.values():
elements_by_plugin[info.plugin][info.name] = info
if name in elements_by_plugin:
# display per-plugin information
plugin_elements = elements_by_plugin[name]
_display_plugin_info(plugin_elements)
elif name in elements:
# display element information
info = elements[name]
_display_element_info(info)
else:
console.print("no such element or plugin")
Exit(code=1)
else:
_display_all_element_info(elements)
|