Skip to content

Commit 4eb4761

Browse files
committed
final changes
1 parent d23ad8f commit 4eb4761

3 files changed

Lines changed: 99 additions & 49 deletions

File tree

README.md

Lines changed: 79 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# CLI Task Tracker
22

3-
CLI Task Tracker is a simple yet powerful command-line application designed to help you manage your tasks directly from your terminal. Built entirely in Python, the project uses only built-in modules (`json`, `sys`, and `datetime`), ensuring a lightweight solution with no external dependencies.
3+
CLI Task Tracker is a simple yet powerful command-line application designed to help you manage your tasks directly
4+
from your terminal. Built entirely in Python, the project uses only built-in modules (`json`, `sys`, and `datetime`),
5+
ensuring a lightweight solution with no external dependencies.
46

57
## Table of Contents
68
- [Overview](#overview)
@@ -36,11 +38,67 @@ No additional packages are required since only built-in modules are used.
3638
### Steps to Install
3739
1. **Clone the Repository:**
3840
``` bash
39-
git clone https://github.com/yourusername/cli-task-tracker.git
41+
git clone https://github.com/MXD-K1/cli-task-tracker.git
4042
cd cli-task-tracker
4143
```
44+
2. **Run it on your terminal:**
45+
``` bash
46+
python task-tarcker-cli.py # your commands go here
47+
```
48+
4249
## Usage
43-
none
50+
Here is a list of the available commands:
51+
1. **Adding a Task:**
52+
- To add a new task, simply use:
53+
``` bash
54+
python cli_task_tracker.py add "Buy groceries"
55+
```
56+
Output: `Successfully added Buy groceries (ID: 3)`
57+
58+
- To add a description to an existing task:
59+
``` bash
60+
python cli_task_tracker.py add 3 -d "Buy groceries and cook diner"
61+
```
62+
63+
- To add a description to a new task:
64+
``` bash
65+
python cli_task_tracker.py add "Buy groceries" -d "Buy groceries and cook diner
66+
```
67+
68+
2. **Updating a Task:**
69+
- To add a new task, simply use:
70+
``` bash
71+
python cli_task_tracker.py update 1 "Buy groceries and cook diner"
72+
```
73+
74+
3. **Deleting a Task:**
75+
76+
Remove a task using its ID:
77+
``` bash
78+
python cli_task_tracker.py delete 1
79+
```
80+
4. **Listing Tasks:**
81+
- View all tasks:
82+
``` bash
83+
python cli_task_tracker.py list
84+
```
85+
- Filter tasks by status:
86+
``` bash
87+
python cli_task_tracker.py list todo
88+
python cli_task_tracker.py list in-progress
89+
python cli_task_tracker.py list done
90+
```
91+
5. **Marking Tasks (Changing Task Status):**
92+
- Mark a task as in-progress:
93+
``` bash
94+
python cli_task_tracker.py mark-in-progress 1
95+
```
96+
- Mark a task as either `todo`, `in-progress`, or `done`:
97+
``` bash
98+
python cli_task_tracker.py mark 1 done
99+
python cli_task_tracker.py mark 1 todo
100+
python cli_task_tracker.py mark 1 in-progress
101+
```
44102
45103
## Task Data Structure
46104
Each task is stored in a JSON file with the following properties:
@@ -79,31 +137,30 @@ Thank you for considering contributing to **CLI Task Tracker**! Your contributio
79137
``` bash
80138
git checkout -b feature/your-feature-name
81139
```
82-
83-
When making your changes:
140+
4. **Make Your Changes:**
84141
- Ensure your code follows the project’s style.
85142
- Write clear, concise commit messages.
86143
- Update documentation **if** needed.
87144

88-
4. **Commit Your Changes**:
89-
90-
``` bash
91-
git commit -am "Add [feature/bug fix]: Brief description of changes"
92-
```
93-
Push Your Branch:
94-
95-
bash
96-
git push origin feature/your-feature-name
97-
Open a Pull Request (PR):
98-
99-
Navigate to the original repository on GitHub.
100-
101-
Open a new PR and describe your changes in detail.
102-
103-
Link to any related issues and explain why your contribution is valuable.
145+
5. **Commit Your Changes:**
146+
``` bash
147+
git commit -am "Add [feature/bug fix]: Brief description of changes"
148+
```
149+
6. **Push Your Branch:**
150+
151+
``` bash
152+
git push origin feature/your-feature-name
153+
```
154+
7. **Open a Pull Request (PR):**
155+
- Navigate to the original repository on GitHub.
156+
- Open a new PR and describe your changes in detail.
157+
- Link to any related issues and explain why your contribution is valuable.
104158

105-
Code Style and Standards
159+
### Code Style and Standards
106160

161+
- Follow the established code style for the project.
162+
- Test your changes thoroughly before submitting a PR.
163+
- Keep commits focused and descriptive.
107164

108165
## License
109166
This project is licensed under the **MIT License** – a permissive open-source license that allows users to freely use,

cli_task_tracker.py

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@
33
import json
44
import sys
55
from typing import Dict
6-
76
import datetime
87

98

10-
# fix bugs
11-
# help is not tested yet
12-
13-
149
def main():
1510
json_file = "tasks.json"
1611
args, do = extract_args()
17-
print(args)
1812

1913
# perform the task
2014
execute_command(args, do, json_file)
@@ -38,7 +32,7 @@ def extract_args(): # Needs refactoring
3832
args["args"] = [task]
3933
elif len(raw_args) == 4:
4034
task_id_or_task = raw_args[1]
41-
args["args"] = [task_id_or_task]
35+
args["args"] = [int(task_id_or_task) if task_id_or_task.isdigit() else task_id_or_task]
4236
if "-d" == raw_args[2]:
4337
description = raw_args[3]
4438
args["args"].append(description)
@@ -197,29 +191,27 @@ def extract_args(): # Needs refactoring
197191
def execute_command(args, do, json_file):
198192
data = get_data(json_file)
199193
task_id = get_id(data)
200-
if args["command"] == "add":
201-
if do:
194+
if do:
195+
if args["command"] == "add":
202196
if len(args["args"]) == 1:
203-
add_task(args["args"][0], task_id, data, json_file)
197+
add_task(args["args"][0], task_id, data, json_file)
204198
else:
205-
add_description(1, data, 11, json_file)
206-
elif args["command"] == "delete":
207-
if do:
199+
if isinstance(args["args"][0], int):
200+
add_description(args["args"][1], args["args"][0], data, json_file)
201+
else: # It will be a str
202+
add_task(args["args"][0], task_id, data, json_file)
203+
add_description(args["args"][1], task_id, data, json_file)
204+
elif args["command"] == "delete":
208205
delete_task(args["args"][0], data, json_file)
209-
elif args["command"] == "update":
210-
if do:
206+
elif args["command"] == "update":
211207
update_task(args["args"][0], args["args"][1], data, json_file)
212-
elif args["command"] == "list":
213-
if do:
208+
elif args["command"] == "list":
214209
list_tasks(data, args["args"][0])
215-
elif args["command"] == "mark":
216-
if do:
210+
elif args["command"] == "mark":
217211
mark_task(data, args["args"][0], args["args"][1], json_file)
218-
else:
219-
pass
220-
# No need to do anything, because extract_args reports error and ignore the invalid command
221-
222-
# then (8) add the rest of the features from roadmap like adding time ...
212+
else:
213+
pass
214+
# No need to do anything, because extract_args reports error and ignore the invalid command
223215

224216

225217
def get_data(json_file):
@@ -256,12 +248,13 @@ def add_task(item, task_id, data, json_file):
256248

257249
def add_description(description, task_id, data, json_file):
258250
if data.get(f"t{task_id}", None) is not None:
259-
data[f"t{task_id}"]["updateAt"] = datetime.datetime.now().strftime("%d-%m-%Y %H:%M:%S")
251+
data[f"t{task_id}"]["UpdatedAt"] = datetime.datetime.now().strftime("%d-%m-%Y %H:%M:%S")
260252
data[f"t{task_id}"]["description"] = description
261253
write_to_json(json_file, data)
262254
print(f"Successfully added description for {data[f"t{task_id}"]["task"]} (ID: {task_id})")
263255
else:
264-
report_error()
256+
report_error(f"No task is associated with the ID {task_id}.", "ID")
257+
265258

266259
def delete_task(task_id, data, json_file):
267260
try:

cli_task_tracker.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def get_data(json_file: str) -> Dict: ...
88
def get_id(data: Dict) -> int: ...
99
def write_to_json(file_name: str, data: Dict) -> None: ...
1010
def add_task(item: str, task_id: int, data: Dict, json_file: str) -> None: ...
11-
def add_description(item: str, task_id: int, data: Dict, json_file: str) -> None: ...
11+
def add_description(description: str, task_id: int, data: Dict, json_file: str) -> None: ...
1212
def delete_task(task_id: int, data: Dict, json_file: str) -> None: ...
1313
def update_task(task_id: int, new_task: str, data: Dict, json_file: str) -> None: ...
1414
def sort_dict_data(task_dict: Tuple[str, Dict[str, Any]]) -> None: ...

0 commit comments

Comments
 (0)