Closed arskiy closed 5 years ago
Great job, thanks! I'll take a look asap!
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?
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.
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} .....
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
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.
Nice.
You can now add a note to "1d" and I'm adding the "Next tuesday / sunday / anything" note