blob: 098e392a3867a18f6580316d9d815a8acee0446d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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])
|