Last active
February 12, 2023 03:20
-
-
Save flrngel/3f17666cd0fc514f08dda851a9fc2d50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python3 | |
import argparse | |
import datetime | |
import os | |
filename = "tid.txt" | |
def list_memos(filename): | |
with open(filename, "r") as file: | |
for line in file: | |
print("- " + line.strip()) | |
parser = argparse.ArgumentParser(description="Save or list Today I Did (TID) memos.") | |
parser.add_argument("-l", "--list", action="store_true", help="List TID memos.") | |
args = parser.parse_args() | |
if args.list: | |
if os.path.exists(filename): | |
list_memos(filename) | |
else: | |
print("No memos found.") | |
else: | |
if os.path.exists(filename): | |
with open(filename, "r") as file: | |
last_update = file.readline().strip() | |
last_update_date = datetime.datetime.strptime(last_update.split(": ")[0], "%Y-%m-%d").date() | |
today = datetime.datetime.now().date() | |
if last_update_date < today: | |
print("It looks like the last update was made on", last_update.split(": ")[0]) | |
response = input("Would you like to clear the history? (yes/no) ").strip().lower() | |
if response == "yes": | |
open(filename, "w").close() | |
print("History cleared.") | |
memo = input("What did you do today? ") | |
with open(filename, "a") as file: | |
file.write(str(datetime.datetime.now().date()) + ": " + memo + "\n") | |
print("Memo saved.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment