How to use the command 'todo' (with examples)
The ’todo’ command is a simple, standards-based CLI (Command Line Interface) todo manager. It allows users to manage their tasks efficiently from the command line. Whether you need to add new tasks, mark them as completed, edit task details, or delete tasks, the ’todo’ command has you covered. In this article, we will explore the various use cases of the ’todo’ command and provide examples for each one.
Use case 1: List startable tasks
Code:
todo list --startable
Motivation: The ’list’ command with the ‘–startable’ option is used to list all the tasks that can be started. This can be useful when you want to see a quick overview of tasks that are ready to be worked on.
Explanation:
todo
: The command itself.list
: Specifies that we want to list tasks.--startable
: An optional flag that filters the tasks and only displays tasks that can be started.
Example Output:
Startable tasks:
- Task 1
- Task 2
- Task 3
Use case 2: Add a new task to the work list
Code:
todo new thing_to_do --list work
Motivation: The ’new’ command allows you to add a new task to a specific task list. By specifying the list name, you can keep your tasks organized and easily manage them later.
Explanation:
todo
: The command itself.new
: Specifies that we want to create a new task.thing_to_do
: The description of the task to be added.--list work
: Specifies the name of the list where the new task should be added. In this case, it is added to the ‘work’ list.
Example Output:
New task added to the 'work' list:
- Task 4: thing_to_do
Use case 3: Add a location to a task with a given ID
Code:
todo edit --location location_name task_id
Motivation: The ’edit’ command allows you to modify task properties. Adding a location to a task can be helpful when you want to associate a specific place with a task, such as a meeting room or a client’s office.
Explanation:
todo
: The command itself.edit
: Specifies that we want to edit a task.--location location_name
: Specifies the location to be added to the task. Replace ’location_name’ with the actual location.task_id
: The ID of the task to be edited.
Example Output:
Task 4 details updated:
- Location: location_name
Use case 4: Show details about a task
Code:
todo show task_id
Motivation: The ‘show’ command provides detailed information about a specific task. This can be useful when you need to review the details of a task or share the task information with others.
Explanation:
todo
: The command itself.show
: Specifies that we want to display task details.task_id
: The ID of the task to be shown.
Example Output:
Details of Task 4:
- Description: thing_to_do
- Location: location_name
- Status: In progress
Use case 5: Mark tasks with the specified IDs as completed
Code:
todo done task_id1 task_id2 ...
Motivation: The ‘done’ command is used to mark tasks as completed. By specifying the task IDs as arguments, you can easily update multiple tasks’ status at once.
Explanation:
todo
: The command itself.done
: Specifies that we want to mark tasks as done.task_id1 task_id2 ...
: The IDs of the tasks to be marked as completed. Separate multiple IDs with spaces.
Example Output:
Tasks 1 and 2 marked as completed.
Use case 6: Delete a task
Code:
todo delete task_id
Motivation: The ‘delete’ command allows you to remove a task from the task list. This can be useful when a task is no longer relevant or has been completed.
Explanation:
todo
: The command itself.delete
: Specifies that we want to delete a task.task_id
: The ID of the task to be deleted.
Example Output:
Task 3 deleted successfully.
Use case 7: Delete done tasks and reset the IDs of the remaining tasks
Code:
todo flush
Motivation: The ‘flush’ command helps you clean up your task list by deleting all the completed tasks and resetting the task IDs. This can be useful for maintaining an organized and clutter-free task list.
Explanation:
todo
: The command itself.flush
: Specifies that we want to delete done tasks and reset the remaining task IDs.
Example Output:
Done tasks deleted successfully.
Remaining tasks IDs reset.
Conclusion:
The ’todo’ command is a versatile tool for managing tasks from the command line. Whether you need to create new tasks, mark them as completed, update task details, or delete tasks, the ’todo’ command provides a simple and efficient way to organize and track your tasks. By exploring each of the use cases described in this article, you can effectively utilize the ’todo’ command to enhance your task management workflow.