feat: expose workflow schema catalog in cli

This commit is contained in:
lda
2026-06-22 22:01:33 +07:00 Verified
parent 6733601372
commit bc89943554
2 changed files with 35 additions and 9 deletions
+1 -2
View File
@@ -79,11 +79,10 @@ app.add_typer(runs.app, name="run")
app.add_typer(sources.app, name="source")
app.add_typer(admin.app, name="admin")
app.add_typer(docs.app, name="docs")
app.add_typer(schema.app, name="schema")
app.add_typer(config_commands.app, name="config")
app.command("explain")(explain.explain_command)
app.command("status")(status.status_command)
app.command("schema")(schema.schema_command)
def main() -> None:
"""Console script entrypoint for `wf`."""
+34 -7
View File
@@ -2,11 +2,38 @@ from __future__ import annotations
import typer
app = typer.Typer(
name="schema",
help=(
"Work in progress: intended to print expected input shapes for wf "
"commands, but currently has no schema subcommands."
),
no_args_is_help=True,
from wf_cli.io import emit_json
from wf_cli.schema_catalog import (
compact_schema_outline,
schema_catalog,
schema_catalog_payload,
verbose_schema_document,
)
def schema_command(
name: str | None = typer.Argument(
None,
help="Schema name or alias (e.g. draft, raw, core, NodeUse). Omit it, or use `list`, to list names.",
),
verbose: bool = typer.Option(
False,
"--verbose",
"-v",
help="Print complete valid JSON Schema; output may be large.",
),
) -> None:
"""Print a compact workflow schema outline or full JSON Schema."""
if name is None or name == "list":
emit_json(schema_catalog_payload())
return
try:
schema_catalog().resolve(name)
except KeyError as exc:
message = exc.args[0] if exc.args else str(exc)
raise typer.BadParameter(message, param_hint="NAME") from exc
emit_json(
verbose_schema_document(name)
if verbose
else compact_schema_outline(name)
)