aboutsummaryrefslogtreecommitdiff
path: root/search.py
diff options
context:
space:
mode:
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