Skip to content

dizzy.generators.commands

dizzy.generators.commands

Commands generator — scaffold def/commands.yaml.

render_scaffold_commands(commands)

Render a LinkML stub for def/commands.yaml from the feat definition.

Source code in dizzy/src/dizzy/generators/commands.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def render_scaffold_commands(commands: list[CommandDef]) -> str:
    """Render a LinkML stub for def/commands.yaml from the feat definition."""
    lines = [
        "id: https://example.org/commands",
        "name: commands",
        "prefixes:",
        "  linkml: https://w3id.org/linkml/",
        "default_range: string",
        "imports:",
        "  - linkml:types",
        "classes:",
    ]
    for cmd in commands:
        lines.append(f"  {cmd.name}:")
        lines.extend(description_lines(cmd.description, "    "))
        lines.append("    attributes: {}")
    lines.append("")
    return "\n".join(lines)

write_scaffold_commands(commands, output_dir)

Write def/commands.yaml; skip if file already exists.

Source code in dizzy/src/dizzy/generators/commands.py
30
31
32
33
34
35
36
37
38
def write_scaffold_commands(commands: list[CommandDef], output_dir: Path) -> None:
    """Write def/commands.yaml; skip if file already exists."""
    dest = output_dir / "def" / "commands.yaml"
    if dest.exists():
        logger.debug("skipped existing file", extra={"path": str(dest)})
        return
    dest.parent.mkdir(parents=True, exist_ok=True)
    dest.write_text(render_scaffold_commands(commands))
    logger.debug("wrote file", extra={"path": str(dest)})