From 0c0546c0826d8c2f2fa5c15315fbeb376af7a3c0 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sun, 22 Mar 2026 18:15:38 +0000 Subject: [PATCH] Initial upload: shell-history-semantic-search v0.1.0 --- src/shell_history_search/parsers/factory.py | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/shell_history_search/parsers/factory.py 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