fts¶
Pure-logic implementation of the full-text-search Alfred action.
fts() is dependency-injected (no global path_enum references) so it
can be unit-tested in isolation. cli.py is responsible for wiring real
paths and sending feedback to Alfred.
- class afwf_fts_anything.fts.ActionEnum(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Alfred action triggered when the user presses Enter on a search result.
- open_url = 'open_url'¶
Pass arg to
afwf.Item.open_url()— suitable for URL-valued args.
- open_file = 'open_file'¶
Pass arg to
afwf.Item.open_file()— suitable for file-path args.
- afwf_fts_anything.fts.fts(dataset_name: str, query: str, dir_datacatalog_root: Path, action: ActionEnum = ActionEnum.open_url, path_error_log: Path | None = None) list[Item][source]¶
Core full-text-search logic for the
ftsAlfred Script Filter.- Parameters:
dataset_name – name of the dataset to search.
query – user’s raw query string (already normalised by the caller — never a
bool).dir_datacatalog_root – root directory of the
DataCatalog; the dataset lives at{dir_datacatalog_root}/{dataset_name}/.action – Alfred action bound to each result item; defaults to
ActionEnum.open_url.path_error_log – when provided and query is empty, an “Open error log” item is appended so the user can access it from Alfred.
Branches
query == "?"— reveal the dataset’s setting file in Finder; returns immediately without touching the index.Otherwise — build the index on first run if absent, then search. An empty query is translated to
"*"(tantivy all-documents wildcard). Falls back to a “No result found” item when the index returns no hits for a non-empty query. Appends the error-log item when query is empty and path_error_log is given.