A simple command-line application to manage a to-do list. This CLI app allows you to add, list, mark tasks as complete, remove tasks, and clear the entire to-do list, all stored in a CSV file.
- Add a Task: Add a new task to the to-do list.
- List Tasks: Display all tasks in a formatted table.
- Mark Task as Complete: Mark a specific task as complete.
- Remove a Task: Remove a specific task by its ID.
- Clear To-Do List: Clear all tasks from the list.
- Go 1.16+
- Cobra
- tablewriter
-
Clone the repository:
git clone https://github.com/yourusername/todo-cli-app.git cd todo-cli-app
-
Install dependencies:
go get -u github.com/spf13/cobra go get -u github.com/olekukonko/tablewriter
-
Build the app:
go build -o todoApp main.go
-
Run the app:
./todoApp
Add a new task to the to-do list. Each task will be assigned a unique ID.
Example:
./todoApp add "Buy groceries"
Display all tasks in a formatted table, showing the task status, ID, and description.
./todoApp list
Example Output:
+--------+----+---------------------+
| Status | ID | Task |
+--------+----+---------------------+
| [ ] | 1 | Buy groceries |
| [x] | 2 | Walk the dog |
| [ ] | 3 | Finish project |
+--------+----+---------------------+
Mark a task as complete by specifying its ID. The status will change from [ ] to [x].
./todoApp complete <taskID>
Example:
./todoApp complete 5
Output:
Taskd ID #5 has been marked as complete.
Remove a task from the to-do list by its ID.
./todoApp remove <taskID>
Example:
./todoApp remove 5
Output:
Task ID #5 has been removed.
Clear all tasks from the to-do list, leaving it empty.
./todoApp clear
Output:
All tasks have been cleared from the to-do list.
AddTaskToCSV: Adds a new task to tasks.csv with a unique ID and an initial status of [ ].
PrintTaskTable: Reads all tasks from tasks.csv and displays them in a formatted table using tablewriter.
MarkTaskComplete: Marks a task as complete by updating the status to [x].
RemoveTaskByID: Removes a task by its ID from tasks.csv.
ClearToDoList: Clears all tasks by truncating tasks.csv.
File Structure
.
├── main.go # Entry point for the CLI app
├── cmd # Directory for Cobra commands
│ ├── add.go # Code for the "add" command
│ ├── list.go # Code for the "list" command
│ ├── complete.go # Code for the "complete" command
│ ├── remove.go # Code for the "remove" command
│ └── clear.go # Code for the "clear" command
└── tasks.csv # CSV file where tasks are stored
Contributing
Feel free to fork the repository and submit pull requests for new features, bug fixes, or improvements. License
This project is licensed under the MIT License.