feat: expose workflow schema catalog in cli
This commit is contained in:
+1
-2
@@ -79,11 +79,10 @@ app.add_typer(runs.app, name="run")
|
|||||||
app.add_typer(sources.app, name="source")
|
app.add_typer(sources.app, name="source")
|
||||||
app.add_typer(admin.app, name="admin")
|
app.add_typer(admin.app, name="admin")
|
||||||
app.add_typer(docs.app, name="docs")
|
app.add_typer(docs.app, name="docs")
|
||||||
app.add_typer(schema.app, name="schema")
|
|
||||||
app.add_typer(config_commands.app, name="config")
|
app.add_typer(config_commands.app, name="config")
|
||||||
app.command("explain")(explain.explain_command)
|
app.command("explain")(explain.explain_command)
|
||||||
app.command("status")(status.status_command)
|
app.command("status")(status.status_command)
|
||||||
|
app.command("schema")(schema.schema_command)
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
"""Console script entrypoint for `wf`."""
|
"""Console script entrypoint for `wf`."""
|
||||||
|
|||||||
@@ -2,11 +2,38 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import typer
|
import typer
|
||||||
|
|
||||||
app = typer.Typer(
|
from wf_cli.io import emit_json
|
||||||
name="schema",
|
from wf_cli.schema_catalog import (
|
||||||
help=(
|
compact_schema_outline,
|
||||||
"Work in progress: intended to print expected input shapes for wf "
|
schema_catalog,
|
||||||
"commands, but currently has no schema subcommands."
|
schema_catalog_payload,
|
||||||
),
|
verbose_schema_document,
|
||||||
no_args_is_help=True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user