pimutils / todoman

✅ A simple, standards-based, cli todo (aka: task) manager.
https://todoman.readthedocs.io
ISC License
483 stars 78 forks source link

Setting "--priority=none" launches in interactive mode #417

Closed Pikrass closed 3 years ago

Pikrass commented 3 years ago

Context: I want to set all my tasks to priority none, so something like:

for i in $(todoman list | sed 's/^ \+//' | cut -d' ' -f1); do
    todoman edit --priority=none $i
done

The problem is, the todoman edit command runs in interactive mode.

I believe the fix is actually really simple:

diff --git i/todoman/cli.py w/todoman/cli.py
index c6aa6ea..5989df6 100644
--- i/todoman/cli.py
+++ w/todoman/cli.py
@@ -412,7 +412,7 @@ def edit(ctx, id, todo_properties, interactive, raw):

     changes = False
     for key, value in todo_properties.items():
-        if value:
+        if value is not None:
             changes = True
             setattr(todo, key, value)

When priority is set to "none", the corresponding value in the todo_properties dict is 0, which is evaluated to False. Checking against None fixes it. The code right after that checks for changes and sets interactive mode if it's False.

I'd make a PR but I couldn't set up a development environment, setup.py gave me an error (apparently because of Debian's version format?), and I didn't want to spend too much time on this at the moment. So I couldn't run (and hence write) tests.

andrewferrier commented 3 years ago

I'm suffering from this bug too. I've opened a pull req: https://github.com/pimutils/todoman/pull/444

WhyNotHugo commented 3 years ago

Fixed via #444