]> us-delaporte.pagekite.me Git - matrix-fridge-bot.git/blob - matrix_fridge_bot/tasks.py
Fix - allow adding items again after they are long expired
[matrix-fridge-bot.git] / matrix_fridge_bot / tasks.py
1 import os
2
3 from invoke import task
4
5 from .db import Data
6
7
8 # Where to store data
9 DATA_DIR = os.environ.get('MATRIX_DATA_DIR', '')
10 DB_FILE = os.environ.get('MATRIX_DB_FILE', 'fridge.db')
11 db_file = os.path.join(DATA_DIR, DB_FILE)
12
13 DATA = Data(db_file)
14
15 @task
16 def add(c, task):
17 '''Add food to the fridge'''
18 result = DATA.add(task)
19 print(result)
20
21 @task
22 def setup(c):
23 '''One time database setup.'''
24 result = DATA.setup()
25 print(result)
26
27
28
29 @task
30 def list(c):
31 '''List good things to eat in the fridge'''
32 result = DATA.list()
33 for item in result:
34 print(f'{item}')
35
36
37 @task
38 def toss(c):
39 result = DATA.to_toss()
40 for item in result:
41 print(f'{item}')
42
43
44 @task
45 def remove(c, item):
46 result = DATA.remove(item)
47 print(result)
48
49
50 @task
51 def filter(c, term):
52 result = DATA.filter(term)
53 for item in result:
54 print(f'{item}')
55
56 @task
57 def debug(c):
58 print(DATA.get_db_file())