aishwarya-task-manager-cli 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aishwarya_task_manager_cli-0.1.0.dist-info/METADATA +107 -0
- aishwarya_task_manager_cli-0.1.0.dist-info/RECORD +9 -0
- aishwarya_task_manager_cli-0.1.0.dist-info/WHEEL +5 -0
- aishwarya_task_manager_cli-0.1.0.dist-info/entry_points.txt +2 -0
- aishwarya_task_manager_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
- aishwarya_task_manager_cli-0.1.0.dist-info/top_level.txt +1 -0
- task_manager/__init__.py +3 -0
- task_manager/cli.py +113 -0
- task_manager/storage.py +85 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aishwarya-task-manager-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A command-line task manager written in Python.
|
|
5
|
+
Author: Aishwarya
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: cli,tasks,productivity
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: build; extra == "dev"
|
|
18
|
+
Requires-Dist: pytest; extra == "dev"
|
|
19
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
20
|
+
Requires-Dist: ruff; extra == "dev"
|
|
21
|
+
Requires-Dist: twine; extra == "dev"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# Task Manager CLI
|
|
25
|
+
|
|
26
|
+
A simple command-line task manager written in Python.
|
|
27
|
+
|
|
28
|
+
## Features
|
|
29
|
+
|
|
30
|
+
- Add tasks
|
|
31
|
+
- List tasks
|
|
32
|
+
- Mark tasks as completed
|
|
33
|
+
- Delete tasks
|
|
34
|
+
- Save tasks between runs in a JSON file
|
|
35
|
+
|
|
36
|
+
## Requirements
|
|
37
|
+
|
|
38
|
+
- Python 3.11 or newer
|
|
39
|
+
|
|
40
|
+
## Development setup
|
|
41
|
+
|
|
42
|
+
Create and activate a virtual environment:
|
|
43
|
+
|
|
44
|
+
```powershell
|
|
45
|
+
python -m venv .venv
|
|
46
|
+
.\.venv\Scripts\Activate.ps1
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Install the package and its development tools:
|
|
50
|
+
|
|
51
|
+
```powershell
|
|
52
|
+
python -m pip install --editable ".[dev]"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
Display help:
|
|
58
|
+
|
|
59
|
+
```powershell
|
|
60
|
+
tasker --help
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Add a task:
|
|
64
|
+
|
|
65
|
+
```powershell
|
|
66
|
+
tasker add "Review Python basics"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
List tasks:
|
|
70
|
+
|
|
71
|
+
```powershell
|
|
72
|
+
tasker list
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Complete a task:
|
|
76
|
+
|
|
77
|
+
```powershell
|
|
78
|
+
tasker complete 1
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Delete a task:
|
|
82
|
+
|
|
83
|
+
```powershell
|
|
84
|
+
tasker delete 1
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Tasks are stored in `tasks.json` in the current directory.
|
|
88
|
+
|
|
89
|
+
## Quality checks
|
|
90
|
+
|
|
91
|
+
Check the code:
|
|
92
|
+
|
|
93
|
+
```powershell
|
|
94
|
+
ruff check .
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Run the tests:
|
|
98
|
+
|
|
99
|
+
```powershell
|
|
100
|
+
pytest
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Run tests with coverage:
|
|
104
|
+
|
|
105
|
+
```powershell
|
|
106
|
+
pytest --cov=task_manager --cov-report=term-missing
|
|
107
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
aishwarya_task_manager_cli-0.1.0.dist-info/licenses/LICENSE,sha256=64qLdXy1MFdUkS5xeTLU-LBMCAUCZp3CnNewasqWLvk,1085
|
|
2
|
+
task_manager/__init__.py,sha256=fz1cTbElCAuoUNZ4bw_Ep65HeE4QFcJ7IuY42DiHlZk,59
|
|
3
|
+
task_manager/cli.py,sha256=fWXDiNSVp4HTTlOiDikflxIeiBGcQrOBWPk442c_9jw,2773
|
|
4
|
+
task_manager/storage.py,sha256=1AfsBjpaQViSyA3sSWHcbMhAhQJ-UUvH2v_SQRZvoTY,1935
|
|
5
|
+
aishwarya_task_manager_cli-0.1.0.dist-info/METADATA,sha256=rJnOMOYRnreGrst7Lb2maAdUGB6ZnzWKKnJN5rX04sk,1882
|
|
6
|
+
aishwarya_task_manager_cli-0.1.0.dist-info/WHEEL,sha256=a-udL2m4V_6Yn8b-uKzWb12RjRxwwMo6ohYFM24tpaY,91
|
|
7
|
+
aishwarya_task_manager_cli-0.1.0.dist-info/entry_points.txt,sha256=QbikjLgyJeBGMDNMyPLv5QxsFwvE973tOIAJ954Rtpo,49
|
|
8
|
+
aishwarya_task_manager_cli-0.1.0.dist-info/top_level.txt,sha256=txVWUWwaSeBBGIFJea7iM-OGDJJYKyVuQPPXqt-CXyw,13
|
|
9
|
+
aishwarya_task_manager_cli-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aishwarya
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
task_manager
|
task_manager/__init__.py
ADDED
task_manager/cli.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"""Command-line interface for the task manager."""
|
|
2
|
+
|
|
3
|
+
from argparse import ArgumentParser, Namespace
|
|
4
|
+
|
|
5
|
+
from task_manager.storage import (
|
|
6
|
+
add_task,
|
|
7
|
+
complete_task,
|
|
8
|
+
delete_task,
|
|
9
|
+
load_tasks,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def build_parser() -> ArgumentParser:
|
|
14
|
+
"""Create and configure the command-line argument parser."""
|
|
15
|
+
parser = ArgumentParser(
|
|
16
|
+
prog="tasker",
|
|
17
|
+
description="Create and manage tasks from the command line.",
|
|
18
|
+
)
|
|
19
|
+
parser.add_argument(
|
|
20
|
+
"--version",
|
|
21
|
+
action="version",
|
|
22
|
+
version="%(prog)s 0.1.0",
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
subparsers = parser.add_subparsers(
|
|
26
|
+
dest="command",
|
|
27
|
+
required=True,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
add_parser = subparsers.add_parser(
|
|
31
|
+
"add",
|
|
32
|
+
help="Add a new task.",
|
|
33
|
+
)
|
|
34
|
+
add_parser.add_argument(
|
|
35
|
+
"title",
|
|
36
|
+
help="Description of the task.",
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
subparsers.add_parser(
|
|
40
|
+
"list",
|
|
41
|
+
help="List all tasks.",
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
complete_parser = subparsers.add_parser(
|
|
45
|
+
"complete",
|
|
46
|
+
help="Mark a task as completed.",
|
|
47
|
+
)
|
|
48
|
+
complete_parser.add_argument(
|
|
49
|
+
"task_id",
|
|
50
|
+
type=int,
|
|
51
|
+
help="ID of the task to complete.",
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
delete_parser = subparsers.add_parser(
|
|
55
|
+
"delete",
|
|
56
|
+
help="Delete a task.",
|
|
57
|
+
)
|
|
58
|
+
delete_parser.add_argument(
|
|
59
|
+
"task_id",
|
|
60
|
+
type=int,
|
|
61
|
+
help="ID of the task to delete.",
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
return parser
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def handle_command(args: Namespace) -> None:
|
|
68
|
+
"""Handle the command selected by the user."""
|
|
69
|
+
if args.command == "add":
|
|
70
|
+
if not args.title.strip():
|
|
71
|
+
print("Task title cannot be empty.")
|
|
72
|
+
return
|
|
73
|
+
|
|
74
|
+
task = add_task(args.title)
|
|
75
|
+
print(f'Added task {task["id"]}: {task["title"]}')
|
|
76
|
+
|
|
77
|
+
elif args.command == "list":
|
|
78
|
+
tasks = load_tasks()
|
|
79
|
+
|
|
80
|
+
if not tasks:
|
|
81
|
+
print("No tasks found.")
|
|
82
|
+
return
|
|
83
|
+
|
|
84
|
+
for task in tasks:
|
|
85
|
+
marker = "x" if task["completed"] else " "
|
|
86
|
+
print(f'[{marker}] {task["id"]}: {task["title"]}')
|
|
87
|
+
|
|
88
|
+
elif args.command == "complete":
|
|
89
|
+
task = complete_task(args.task_id)
|
|
90
|
+
|
|
91
|
+
if task is None:
|
|
92
|
+
print(f"Task {args.task_id} was not found.")
|
|
93
|
+
else:
|
|
94
|
+
print(f'Completed task {task["id"]}: {task["title"]}')
|
|
95
|
+
|
|
96
|
+
elif args.command == "delete":
|
|
97
|
+
task = delete_task(args.task_id)
|
|
98
|
+
|
|
99
|
+
if task is None:
|
|
100
|
+
print(f"Task {args.task_id} was not found.")
|
|
101
|
+
else:
|
|
102
|
+
print(f'Deleted task {task["id"]}: {task["title"]}')
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def main() -> None:
|
|
106
|
+
"""Run the task manager CLI."""
|
|
107
|
+
parser = build_parser()
|
|
108
|
+
args = parser.parse_args()
|
|
109
|
+
handle_command(args)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
if __name__ == "__main__":
|
|
113
|
+
main()
|
task_manager/storage.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""Read and write task data."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import TypedDict
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Task(TypedDict):
|
|
9
|
+
"""Structure of one task."""
|
|
10
|
+
|
|
11
|
+
id: int
|
|
12
|
+
title: str
|
|
13
|
+
completed: bool
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
DEFAULT_TASKS_FILE = Path("tasks.json")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def load_tasks(file_path: Path = DEFAULT_TASKS_FILE) -> list[Task]:
|
|
20
|
+
"""Load tasks from a JSON file."""
|
|
21
|
+
if not file_path.exists():
|
|
22
|
+
return []
|
|
23
|
+
|
|
24
|
+
with file_path.open(encoding="utf-8") as file:
|
|
25
|
+
return json.load(file)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def save_tasks(
|
|
29
|
+
tasks: list[Task],
|
|
30
|
+
file_path: Path = DEFAULT_TASKS_FILE,
|
|
31
|
+
) -> None:
|
|
32
|
+
"""Save tasks to a JSON file."""
|
|
33
|
+
with file_path.open("w", encoding="utf-8") as file:
|
|
34
|
+
json.dump(tasks, file, indent=2, ensure_ascii=False)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def add_task(
|
|
38
|
+
title: str,
|
|
39
|
+
file_path: Path = DEFAULT_TASKS_FILE,
|
|
40
|
+
) -> Task:
|
|
41
|
+
"""Create and save a new task."""
|
|
42
|
+
tasks = load_tasks(file_path)
|
|
43
|
+
next_id = max((task["id"] for task in tasks), default=0) + 1
|
|
44
|
+
|
|
45
|
+
task: Task = {
|
|
46
|
+
"id": next_id,
|
|
47
|
+
"title": title.strip(),
|
|
48
|
+
"completed": False,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
tasks.append(task)
|
|
52
|
+
save_tasks(tasks, file_path)
|
|
53
|
+
return task
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def complete_task(
|
|
57
|
+
task_id: int,
|
|
58
|
+
file_path: Path = DEFAULT_TASKS_FILE,
|
|
59
|
+
) -> Task | None:
|
|
60
|
+
"""Mark a task as completed."""
|
|
61
|
+
tasks = load_tasks(file_path)
|
|
62
|
+
|
|
63
|
+
for task in tasks:
|
|
64
|
+
if task["id"] == task_id:
|
|
65
|
+
task["completed"] = True
|
|
66
|
+
save_tasks(tasks, file_path)
|
|
67
|
+
return task
|
|
68
|
+
|
|
69
|
+
return None
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def delete_task(
|
|
73
|
+
task_id: int,
|
|
74
|
+
file_path: Path = DEFAULT_TASKS_FILE,
|
|
75
|
+
) -> Task | None:
|
|
76
|
+
"""Delete a task."""
|
|
77
|
+
tasks = load_tasks(file_path)
|
|
78
|
+
|
|
79
|
+
for index, task in enumerate(tasks):
|
|
80
|
+
if task["id"] == task_id:
|
|
81
|
+
deleted_task = tasks.pop(index)
|
|
82
|
+
save_tasks(tasks, file_path)
|
|
83
|
+
return deleted_task
|
|
84
|
+
|
|
85
|
+
return None
|