diff --git a/src/shell_history_search/parsers/factory.py b/src/shell_history_search/parsers/factory.py new file mode 100644 index 0000000..0668093 --- /dev/null +++ b/src/shell_history_search/parsers/factory.py @@ -0,0 +1,28 @@ +from typing import Type + +from shell_history_search.parsers.bash import BashHistoryParser +from shell_history_search.parsers.zsh import ZshHistoryParser +from shell_history_search.parsers.fish import FishHistoryParser +from shell_history_search.parsers import HistoryParser + + +def get_parser(shell_type: str) -> HistoryParser: + parsers: dict[str, Type[HistoryParser]] = { + "bash": BashHistoryParser, + "zsh": ZshHistoryParser, + "fish": FishHistoryParser, + } + + parser_class = parsers.get(shell_type.lower()) + if parser_class is None: + raise ValueError(f"Unknown shell type: {shell_type}") + + return parser_class() + + +def get_all_parsers() -> list[HistoryParser]: + return [ + BashHistoryParser(), + ZshHistoryParser(), + FishHistoryParser(), + ] \ No newline at end of file