aesophor / py-todo

📋 Lightweight reminder / todo-list in cli
https://www.reddit.com/r/unixporn/comments/9qy35q/oc_pytodo_a_lightweight_reminder_in_cli/
MIT License
107 stars 22 forks source link

Adding some features // See description. #6

Closed arskiy closed 5 years ago

arskiy commented 5 years ago

You can now add a note to "1d" and I'm adding the "Next tuesday / sunday / anything" note

aesophor commented 5 years ago

Great job, thanks! I'll take a look asap!

aesophor commented 5 years ago

I think there is a potential bug. For example, suppose today is Monday, and if a user type "3d", then it will show "Next Thursday". Maybe we should add an extra if statement to check if it should be "This" or "Next" Thursday? What do you think?

arskiy commented 5 years ago

Oh, we can easily fix this. I made that mistake because in my country we talk like that. Sorry for the confusion, haha. We just have to change the array.

I'm also looking forward into removing multiple notes at the same time, like

-r 0 1 or -r -a to clear all notes

As we can't edit files because that would change the date I'm just going to add that.

arskiy commented 5 years ago

Done everything I said above, with the exception that -r removes ONE note and -c removes ALL notes or everything in between two ranges provided.

My explanation is confusing, so here's an example:

todo -c 2 6 Removed {note} Removed {note} .....

aesophor commented 5 years ago

Thanks a lot!! I'll merge your PR. Thank you so much for helping me out.

Also, I've successfully implemented varargs by packing sys.argv[2:] into a list, and then converts all elements into int.

todo -r 3
todo -r 3 4 5

For the weekday part, I've come up with a way to deal with the this/next problem accurately. For example, current code could produce the following bug (I implement this part myself today and encountered this very same problem):

Suppose today is Friday and that we type todo -a "SomeTitle" 5d:

You have 1 items left on the reminder!
0) SomeTitle (This Thursday; 5 days left)

It should be "Next Thursday", but it writes "This Thursday" because 0 < 5 <= 6.

I solved this by calculating days_to_next_week and weeks_left, and used weeks_left to decide whether "This" or "Next" should be printed.

The list of ["", "Next Monday" ...] is also redundant. exp_date.strftime("%A") returns its weekday in a string.

Thank you again for your patience reading all of these! I hope it's okay if I merge your PR and then replace some of yours with my own code.

EDIT: grammar

aesophor commented 5 years ago

I also implemented user configuration in ~/.config/py-todo/config:

detail_mode = true / false
week_start_day = Sun / Mon

When detail_mode is false, strings like "Next Monday", "This Friday"... etc will not show, and vice versa. week_start_day is self explanatory.

arskiy commented 5 years ago

Nice.