animedex.entry._cli_factory

CLI helpers: shared option decorators, output rendering, --jq <expr> filter, and the register_subcommand factory used to bind a Python API function to a Click subcommand without hand-written wrappers per endpoint.

common_options

animedex.entry._cli_factory.common_options(func: Callable) Callable[source]

Decorator: attach --json, --jq, --no-cache, --cache, --rate, --no-source flags to a CLI subcommand.

--jq filters the rendered JSON through the bundled jq wheel. A syntactically bad expression, runtime error (e.g. 1/0, error("…")), or invalid-JSON input surfaces as a typed ApiError(reason="jq-failed"); an uninstalled wheel surfaces as reason="jq-missing". _apply_jq rewraps either as click.ClickException so the CLI exits non-zero with a clean one-line error rather than a Python traceback.

emit

animedex.entry._cli_factory.emit(result, *, json_flag: bool, jq_expr: str | None, no_source: bool)[source]

Render result (single model or list) and echo it to stdout. Picks JSON or TTY based on flags + isatty.

register_subcommand

animedex.entry._cli_factory.register_subcommand(group: Group, name: str, fn: Callable, *, help: str | None = None, command_aliases: List[str] = None, guidance_override: str | None = None)[source]

Bind a Python API fn as a Click subcommand on group.

Argument inference:

  • Positional parameters with no default → click.argument.

  • Keyword parameters with default → click.option.

  • config / no_cache / cache_ttl / rate are injected via common_options() (suppressed from auto-binding).

The wrapped command builds the Config from the common flags and passes it as config=.... The function’s return value is rendered via emit().