-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
54 lines (41 loc) · 1.54 KB
/
main.py
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
import argparse
from task_manager.manager import TaskManager
from storage import Storage
from Commands.commands import create_command
def main():
storage = Storage()
manager = TaskManager(storage)
parser = argparse.ArgumentParser(description="Task Management System")
subparsers = parser.add_subparsers(dest="command", help="Available commands")
add_parser = subparsers.add_parser(
"add", help="Add a new task(poetry run python main.py add -h)"
)
add_parser.add_argument("--title", required=True, help="Task title(required)")
add_parser.add_argument(
"--description", required=True, help="Task description(required)"
)
complete_parser = subparsers.add_parser(
"complete",
help="Mark a task as completed(poetry run python main.py complete -h)",
)
complete_parser.add_argument("id", type=str, help="Task ID")
list_parser = subparsers.add_parser(
"list", help="List all tasks(poetry run python main.py list -h)"
)
list_parser.add_argument(
"--incomplete", action="store_true", help="Show only incomplete tasks"
)
subparsers.add_parser("report", help="Generate a report")
args = parser.parse_args()
command = create_command(manager, args)
if command:
command.execute()
else:
parser.print_help()
if __name__ == "__main__":
main()
# # python main.py add --title "New Task" --description "Task description"
# # python main.py list
# # python main.py list --incomplete
## python main.py complete id
# # python main.py report