-
-
Notifications
You must be signed in to change notification settings - Fork 984
Expand file tree
/
Copy path__init__.py
More file actions
32 lines (25 loc) · 869 Bytes
/
__init__.py
File metadata and controls
32 lines (25 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Parser registry for clink."""
from __future__ import annotations
from .base import BaseParser, ParsedCLIResponse, ParserError
from .claude import ClaudeJSONParser
from .codex import CodexJSONLParser
from .copilot import CopilotJSONLParser
from .gemini import GeminiJSONParser
_PARSER_CLASSES: dict[str, type[BaseParser]] = {
CodexJSONLParser.name: CodexJSONLParser,
GeminiJSONParser.name: GeminiJSONParser,
ClaudeJSONParser.name: ClaudeJSONParser,
CopilotJSONLParser.name: CopilotJSONLParser,
}
def get_parser(name: str) -> BaseParser:
normalized = (name or "").lower()
if normalized not in _PARSER_CLASSES:
raise ParserError(f"No parser registered for '{name}'")
parser_cls = _PARSER_CLASSES[normalized]
return parser_cls()
__all__ = [
"BaseParser",
"ParsedCLIResponse",
"ParserError",
"get_parser",
]