-
Notifications
You must be signed in to change notification settings - Fork 0
/
tw
executable file
·66 lines (54 loc) · 1.86 KB
/
tw
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/python3
# Author: Venkata Naga Sai Nivas Mangu
# Contact: sainonbeat99@gmail.com
# Import SQLite
import sqlite3
# Import sys for taking command line arguments
import sys
# SOLVING THE PATH PROBLEM
from config.definitions import ROOT_DIR
import os
# Import functions for DB operations
from src.crud_functions import delete_all_finished_tasks, insert_tasks, read_tasks, update_tasks, delete_task, help
from src.wallpaper_functions import create_wallpaper
# Create connection to the database
DB_PATH = os.path.join(ROOT_DIR, "db", "todo.db")
connection = sqlite3.connect(DB_PATH)
cursor = connection.cursor()
# Create a table in the database
create_table = """
CREATE TABLE IF NOT EXISTS todo(
task_name TEXT UNIQUE,
status BOOLEAN
)"""
cursor.execute(create_table)
# Define flag for insert_tasks
if len(sys.argv) > 1:
if sys.argv[1] == "-i" or sys.argv[1] == "i" or sys.argv[1] == "--insert":
try:
insert_tasks(sys.argv[2])
create_wallpaper()
except IndexError:
print("Not enough arguments. Enter the name of the task.")
print("Try the -h flag for the help menu.")
# Define flag for delete_task
elif sys.argv[1] == "-d" or sys.argv[1] == "d" or sys.argv[1] == "--delete":
try:
delete_task(sys.argv[2])
create_wallpaper()
except IndexError:
print("Not enough arguments. Enter the name of the task.")
print("Try the -h flag for the help menu.")
# Define flag for update_tasks
elif sys.argv[1] == "-u" or sys.argv[1] == "u" or sys.argv[1] == "--update":
update_tasks()
create_wallpaper()
# Delete all finished tasks
elif sys.argv[1] == "-df" or sys.argv[1] == "df" or sys.argv[1] == "--delete-finished":
delete_all_finished_tasks()
create_wallpaper()
# Define flag for help
elif sys.argv[1] == "-h" or sys.argv[1] == "h" or sys.argv[1] == "--help":
help()
else:
print(read_tasks())