Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/parsemux/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,15 @@ def detect(
@app.command()
def schema(
command: Optional[str] = typer.Argument(None, help="Command name (omit for all)"),
output_schema: bool = typer.Option(False, "--output-schema", help="Print the ParseResult JSON Schema"),
) -> None:
"""Show machine-readable schema for CLI commands (for AI agents)."""
if output_schema:
from parsemux.core.models import ParseResult

typer.echo(json.dumps(ParseResult.model_json_schema(), indent=2))
return
Comment on lines 217 to +226
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema command docstring says it shows machine-readable schemas for CLI commands, but with --output-schema it outputs the Pydantic JSON Schema for ParseResult instead. Please update the docstring/help text (and the command-schemas payload below, if that’s meant to be complete for agents) to reflect this additional behavior/flag.

Copilot uses AI. Check for mistakes.

schemas = {
"parse": {
"description": "Parse a document and extract structured content",
Expand Down
31 changes: 31 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import json

from typer.testing import CliRunner

from parsemux import __version__
from parsemux.cli.main import app

runner = CliRunner()


def test_version_command_outputs_version() -> None:
result = runner.invoke(app, ["version"])

assert result.exit_code == 0
assert result.stdout.strip() == f"parsemux {__version__}"


def test_version_flag_outputs_version() -> None:
result = runner.invoke(app, ["--version"])

assert result.exit_code == 0
assert result.stdout.strip() == f"parsemux {__version__}"


Comment on lines +18 to +24
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--version isn’t implemented in the Typer app (no callback/option defines it in src/parsemux/cli/main.py), so this test will fail with an “No such option: --version” error. Either add a global --version option on the app callback (printing parsemux {__version__}) or remove this test if only the version subcommand is supported.

Suggested change
def test_version_flag_outputs_version() -> None:
result = runner.invoke(app, ["--version"])
assert result.exit_code == 0
assert result.stdout.strip() == f"parsemux {__version__}"

Copilot uses AI. Check for mistakes.
def test_schema_output_schema_prints_parse_result_schema() -> None:
result = runner.invoke(app, ["schema", "--output-schema"])

assert result.exit_code == 0
payload = json.loads(result.stdout)
assert payload["title"] == "ParseResult"
assert "properties" in payload
Loading