aboutsummaryrefslogtreecommitdiff
path: root/search.py
diff options
context:
space:
mode:
authorChristian Cleberg <hello@cleberg.net>2025-06-04 13:24:22 -0500
committerChristian Cleberg <hello@cleberg.net>2025-06-04 13:24:22 -0500
commit8bbac67df8450b021914725a756a029667b8f585 (patch)
tree1e5f13a29e6a4542fb5976dc74b15db2e89b2a32 /search.py
downloadcrumb-8bbac67df8450b021914725a756a029667b8f585.tar.gz
crumb-8bbac67df8450b021914725a756a029667b8f585.tar.bz2
crumb-8bbac67df8450b021914725a756a029667b8f585.zip
feat: initial commit
Diffstat (limited to 'search.py')
-rw-r--r--search.py27
1 files changed, 27 insertions, 0 deletions
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 <search term>")
+ else:
+ search_log(sys.argv[1]) \ No newline at end of file