Skip to content

CLI⚓︎

cli ⚓︎

Command-line interface for static Gherkin data table validation.

The CLI exposes two operations: check validates Gherkin data tables against a schema without executing pytest scenarios, and describe renders a schema contract for humans or tools.

Info

The public console script and python -m talika both delegate to main() in this module.

_import_object ⚓︎

_import_object(reference: str) -> Any

Import a module:attribute or path.py:attribute reference.

Parameters:

  • reference (str) –

    Import reference supplied by the CLI user.

Returns:

  • Any

    The referenced Python object.

Raises:

  • ValueError

    If the reference does not use module:attribute syntax.

  • ImportError

    If a referenced Python file cannot be imported.

  • AttributeError

    If the attribute path cannot be resolved.

Warning

File references are imported under generated module names. They are intended for CLI loading, not for establishing stable import names.

_schema ⚓︎

_schema(reference: str) -> type[BaseTable]

Load and validate a table schema import reference.

Parameters:

  • reference (str) –

    module:Schema or path.py:Schema reference.

Returns:

Raises:

  • TypeError

    If the reference does not resolve to a BaseTable subclass.

Info

Validation happens before command execution so user-facing errors point at import configuration rather than producing partial output.

_context ⚓︎

_context(reference: str | None) -> Mapping[str, Any] | None

Call an optional zero-argument project context factory.

Parameters:

  • reference (str | None) –

    Optional import reference to a callable.

Returns:

  • Mapping[str, Any] | None

    None or the mapping returned by the project factory.

Raises:

  • TypeError

    If the reference is not callable or does not return a mapping.

Warning

The factory is executed by static checking. It should be deterministic and avoid external side effects.

_diagnostic_data ⚓︎

_diagnostic_data(diagnostic: Diagnostic) -> dict[str, Any]

Return Model v1 fields plus supported legacy aliases.

_diagnostic_payload ⚓︎

_diagnostic_payload(diagnostic: FeatureDiagnostic) -> dict[str, Any]

Convert one feature diagnostic to a stable CLI JSON object.

Parameters:

Returns:

  • dict[str, Any]

    Dictionary containing file identity, scenario identity, and structured

  • dict[str, Any]

    table error attributes.

Info

The shape is intentionally flat so CI systems and editor integrations can consume diagnostics without understanding Python exception objects.

_print_json ⚓︎

_print_json(payload: Mapping[str, Any]) -> None

Print JSON with deterministic ordering.

Parameters:

  • payload (Mapping[str, Any]) –

    JSON-compatible mapping to render.

Info

Sorted keys make CLI output easier to snapshot in tests and compare in automation logs.

_checker_failure ⚓︎

_checker_failure(exc: Exception) -> TableError

Normalize an operational CLI failure without exposing a traceback.

_render_checker_failure ⚓︎

_render_checker_failure(error: TableError, output_format: str) -> None

Render a controlled checker-level failure in text or JSON form.

_render_describe_text ⚓︎

_render_describe_text(schema: type[BaseTable]) -> str

Return a compact human-readable schema contract.

Parameters:

Returns:

  • str

    Multi-line text containing orientation, policies, fields, and variants.

Info

JSON output uses schema.describe().as_dict(). This renderer is optimized for quick terminal inspection.

build_parser ⚓︎

build_parser() -> ArgumentParser

Create the public argument parser.

Returns:

  • ArgumentParser

    Configured argparse.ArgumentParser for CLI commands.

Example

parser = build_parser()
args = parser.parse_args(["describe", "pkg:Schema"])

main ⚓︎

main(argv: Sequence[str] | None = None) -> int

Run the CLI and return a conventional process exit code.

Parameters:

  • argv (Sequence[str] | None, default: None ) –

    Optional argument sequence. None reads process arguments.

Returns:

  • int

    0 for success, 1 for validation failures, or 2 when filters

  • int

    match no tables.

Raises:

  • SystemExit

    Through argparse only when command syntax is invalid.

Warning

check parses matching tables and runs project parsers/validators. Use --context-factory for deterministic dependencies.