MCPcopy Index your code
hub / github.com/idank/explainshell / diff_extractors_cmd

Function diff_extractors_cmd

explainshell/manager.py:987–1039  ·  view source on GitHub ↗

Compare two extractors head-to-head. SPEC is A..B format (e.g. llm:openai/gpt-5-mini..llm:openai/gpt-5).

(
    ctx: click.Context,
    batch: int | None,
    spec: str,
    files: tuple[str, ...],
)

Source from the content-addressed store, hash-verified

985@click.argument("files", nargs=-1, required=True)
986@click.pass_context
987def diff_extractors_cmd(
988 ctx: click.Context,
989 batch: int | None,
990 spec: str,
991 files: tuple[str, ...],
992) -> None:
993 """Compare two extractors head-to-head.
994
995 SPEC is A..B format (e.g. llm:openai/gpt-5-mini..llm:openai/gpt-5).
996 """
997 if ".." not in spec:
998 raise click.UsageError(
999 f"invalid spec: {spec!r} "
1000 "(expected A..B, e.g. llm:openai/gpt-5-mini..llm:openai/gpt-5)"
1001 )
1002 parts = spec.split("..", 1)
1003 try:
1004 left = _parse_mode(parts[0])
1005 right = _parse_mode(parts[1])
1006 except ValueError as e:
1007 raise click.UsageError(str(e))
1008
1009 if batch is not None:
1010 if batch < 1:
1011 raise click.UsageError("--batch must be >= 1")
1012 _, left_model = left
1013 _, right_model = right
1014 has_batch_side = any(
1015 m is not None and m.startswith(_BATCH_MODEL_PREFIXES)
1016 for m in (left_model, right_model)
1017 )
1018 if not has_batch_side:
1019 raise click.UsageError(
1020 "--batch requires at least one side with a batch-capable model "
1021 "(gemini/, openai/, or azure/)"
1022 )
1023
1024 try:
1025 gz_files = util.collect_gz_files(list(files))
1026 except ValueError as e:
1027 raise click.UsageError(str(e))
1028 if not gz_files:
1029 raise click.UsageError("No .gz files found.")
1030
1031 run_dir: str = _ensure_run_dir(ctx)
1032 t0 = time.monotonic()
1033 batch_result = _run_diff_extractors(
1034 gz_files, left, right, run_dir, batch_size=batch
1035 )
1036 elapsed = time.monotonic() - t0
1037 rc = _log_summary(batch_result, 0, elapsed)
1038 if rc != 0:
1039 sys.exit(rc)
1040
1041
1042# ---------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 4

_parse_modeFunction · 0.85
_ensure_run_dirFunction · 0.85
_run_diff_extractorsFunction · 0.85
_log_summaryFunction · 0.85

Tested by

no test coverage detected