foobuzz / todo

A simple command line todo list manager which can be as powerful as you want it to be.
MIT License
380 stars 46 forks source link

Removing todo items or context doesn't reset todo counter #22

Open EssamWisam opened 7 months ago

EssamWisam commented 7 months ago

Consider repeatedly running:

todo rmctx pizza_list --force
todo add "Pepperoni" --context pizza_list
todo add "Margarita" --context pizza_list
todo add "Veggie" --context pizza_list
todo add "Supreme"  --context pizza_list
todo pizza_list

The todo item counter keeps incrementing forever.

EssamWisam commented 7 months ago

Could also not find a way to delete all todos (reset/drop the database) to achieve this (reset counter). Not even uninstalling then reinstalling the package. Any help would be appreciated.

foobuzz commented 7 months ago

Hello!

Yes, previously removed IDs can't be used by new tasks. One advantage of this behavior is that if you have any external reference to a removed task ID (i.e. you have written it down somewhere back when the task existed), there cannot be any ambiguity with a new task that would have "taken its place". I believe it is typical behavior in many applications not to allow the recycling of IDs.

Also, todo indeed does not remove its application files upon uninstalling it, and a re-installation will re-use the application files from the previous installation.

If you want to completely "reset" all todo data, you can first identify where it is located with the command:

todo --location

which will print the location of todo's data directory. You can then remove this directory with rm -r. I would advice making a backup of the directory beforehand just in case as the removal will of course be irreversible.

EssamWisam commented 7 months ago

Well I think in this case that keeping the index makes sense if a task was marked as done. Meanwhile, if I remove a task, it's likely that it doesn't exist anywhere physically (or I don't want it to if it does). Consider if someone gets access to my todo and decides to add 20 useless tasks (or I do with a script by mistake!); after removing them, I won't be so happy that it's impossible to reset it to the original state (in terms of the index).

In all cases, I understand your point, the task removed could somehow still exist physically. In this case, it would be nice to have both options. Regardless, for my particular use case being able to rm -r the todo to reset it is sufficient. Thank you for helping.

Thanks for this nice project. It's the most feature-rich and comprehensive Todo CLI that I have found except for the fact that it's nontrivial to move individual items from one context to another xD.

foobuzz commented 7 months ago

Thanks for the feedback!

I'll consider adding an option to recycle IDs from removed tasks depending on how easy it is to implement.

it's nontrivial to move individual items from one context to another

The command is todo task <id> -c <context>, but I guess you would like to do it for multiple IDs in one command. Support for multiple IDs for the task command is something I intend to implement in the next version.

EssamWisam commented 7 months ago

The command is todo task <id> -c <context> So this moves the task with id id from whatever context it currently is in to <context> right?

I wonder if this is reflected in the reference as I was looking for that. Also, the fact that it can't done be done for multiple ids is okay for me.

Thank you.