INNER CODE UNIT · Python

format_option

torognes/vsearch · completion/scripts/gen_zsh.py:70

def format_option(s: spec_mod.Spec, opt: spec_mod.Option) -> list[str]:
    """Return one or two `_arguments` specs (one for --long, one for -short)."""
    action = arg_action(s, opt)
    d = arg_desc(opt.desc)
    out = [sh_squote(f"{opt.name}[{d}]{action}")]
    if opt.short:
        out.append(sh_squote(f"{opt.short}[{d}]{action}"))
    return out


def emit_block(label: str, specs: list[str], indent: str = "        ") -> list[str]:
    """Emit a single `_arguments -s ...` call indented for a case branch."""
    if not specs:
        return [f"{indent}_arguments -s"]
    lines = [f"{indent}_arguments -s \\"]
    for i, sp in enumerate(specs):
        suffix = " \\" if i < len(specs) - 1 else ""
        lines.append(f"{indent}    {sp}{suffix}")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…