Marmiz / todo-cli

Minimal TODOs inside your terminal. Learning project for Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Broken json after re-adding a completed task

secsaba opened this issue · comments

Steps to reproduce:

cargo run -- add "make coffee"
cargo run -- complete "make coffee"
cargo run -- add "make coffee"

cat db.json
{
"make coffee": true
}}

Observe the two closing brackets at the end of the file.

This happens because the file is not truncated when writing. The "true" is one character lesser than "false" and the last closing brackets remains in place. To fix in "fn save(self)" the file OpenOptions should contain the .truncate(true) method also.

Hi @secsaba, thanks for reporting, and finding the solution to the issue.
Great job!

Do you want to contribute by submitting a PR?
No worries if you can't, I will take care of it.

Thanks for your help on this! 👍

Incidentally freeCodeCamp has a guide on how to do it.

Take your time, and if you need help just shout out and I'll try to help 👍

Your change is now merged into the source code: well done on your first PR. 🥳