File size: 618 Bytes
1ac9488 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import json, os
def save_goal(goal):
os.makedirs("goals", exist_ok=True)
goal_data = {
"goal": goal,
"status": "pending"
}
with open(f"goals/{int(time.time())}.json", "w") as f:
json.dump(goal_data, f)
def list_goals():
goal_files = sorted(os.listdir("goals")) if os.path.exists("goals") else []
goals = []
for gf in goal_files[-10:]: # Show last 10 goals
with open(f"goals/{gf}", "r") as f:
data = json.load(f)
goals.append(f"🎯 {data['goal']} — [{data['status']}]")
return "\n".join(goals) if goals else "No goals yet."
|