Initial upload: shell-history-semantic-search v0.1.0
Some checks failed
CI / test (push) Has been cancelled
Some checks failed
CI / test (push) Has been cancelled
This commit is contained in:
28
src/shell_history_search/parsers/factory.py
Normal file
28
src/shell_history_search/parsers/factory.py
Normal file
@@ -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(),
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user