Skip to content

todo remove command

Again, removing project(database) means removing our .json file. The most naive way is to create the file and pass the project name as an argument:

$ touch
$ tree
└── TODO
    └── todo

1 directory, 3 files
import os

def remove(project_name: str) -> None:
    Remove the .json file with a given project name

        project_name (str): The name of the project

    Return: None
    print("Removed: ", project_name)

Let's get help and remove our daily project:

$ ./todo -h
usage: todo [-h] [-v] {init,remove} ...


positional arguments:
    init         Initialize the .json file with given name
    remove       Remove the .json file with given project name

optional arguments:
  -h, --help     show this help message and exit
  -v, --version  show program's version number and exit
$ ./todo remove daily
Removed:  daily

The final tree:

$ tree -I __pycache__
└── todo

0 directories, 3 files

The next command is todo rename which should rename our project.