MCPcopy Create free account
hub / github.com/idank/explainshell / _run_lexgrog

Function _run_lexgrog

explainshell/manpage.py:45–60  ·  view source on GitHub ↗

Run lexgrog on a man page and return the raw synopsis string. Raises FileNotFoundError if the file does not exist, and RuntimeError if lexgrog fails or produces no output.

(gz_path: str, name: str)

Source from the content-addressed store, hash-verified

43
44
45def _run_lexgrog(gz_path: str, name: str) -> str:
46 """Run lexgrog on a man page and return the raw synopsis string.
47
48 Raises FileNotFoundError if the file does not exist, and RuntimeError
49 if lexgrog fails or produces no output.
50 """
51 if not os.path.isfile(gz_path):
52 raise FileNotFoundError(f"manpage file not found: {gz_path}")
53 proc = subprocess.run(
54 ["lexgrog", gz_path], capture_output=True, text=True, timeout=300
55 )
56 if proc.stderr:
57 logger.warning("lexgrog stderr for %s: %s", name, proc.stderr)
58 if not proc.stdout or not proc.stdout.strip():
59 raise RuntimeError(f"lexgrog produced no output for {gz_path}")
60 return proc.stdout.rstrip()
61
62
63def get_synopsis_and_aliases(gz_path: str) -> tuple[str | None, list[tuple[str, int]]]:

Callers 1

get_synopsis_and_aliasesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected