From 8bbac67df8450b021914725a756a029667b8f585 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Wed, 4 Jun 2025 13:24:22 -0500 Subject: feat: initial commit --- search.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 search.py (limited to 'search.py') diff --git a/search.py b/search.py new file mode 100644 index 0000000..098e392 --- /dev/null +++ b/search.py @@ -0,0 +1,27 @@ +import sys +import os + +LOG_PATH = os.path.expanduser("~/.crumb/history.org") + +def search_log(query): + if not os.path.exists(LOG_PATH): + print("No history file found.") + return + + with open(LOG_PATH, "r") as f: + entries = f.read().split("* ")[1:] # split on org-mode headings + + found = 0 + for entry in entries: + if query.lower() in entry.lower(): + print(f"* {entry.strip()}\n") + found += 1 + + if found == 0: + print("No matches found.") + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Usage: search_crumb.py ") + else: + search_log(sys.argv[1]) \ No newline at end of file -- cgit v1.2.3-70-g09d2