todotxt / todo.txt-cli

☑️ A simple and extensible shell script for managing your todo.txt file.
http://todotxt.org
GNU General Public License v3.0
5.55k stars 712 forks source link

How is todo.sh [do] supposed to work? #401

Open chrysle opened 1 year ago

chrysle commented 1 year ago

Do you want to request a feature or report a bug?

I think a bug.

What is the current behavior?

The todo.sh do command doesn't seem to work as described in the usage.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

I have done some tests:

user@penguin:~/repos/todo.txt-cli$ ./todo.sh do 1#, 2#
usage: todo.sh do ITEM#[, ITEM#, ITEM#, ...]
user@penguin:~/repos/todo.txt-cli$ ./todo.sh do 1, 2#
1 x 2023-01-17 Important task @github
TODO: 1 marked as done.
usage: todo.sh do ITEM#[, ITEM#, ITEM#, ...]
user@penguin:~/repos/todo.txt-cli$ ./todo.sh do 1 2#
TODO: 1 is already marked done.
usage: todo.sh do ITEM#[, ITEM#, ITEM#, ...]
user@penguin:~/repos/todo.txt-cli$ ./todo.sh do 2 3 #
2 x 2023-01-17 Quite unimportant test task
TODO: 2 marked as done.
3 x 2023-01-17 Quite unimportant test task
TODO: 3 marked as done.
x 2023-01-17 Important task @github
x 2023-01-17 Quite unimportant test task
x 2023-01-17 Quite unimportant test task
TODO: /home/user/todo.txt archived.
user@penguin:~/repos/todo.txt-cli$ ./todo.sh do 4 5#
4 x 2023-01-17 Quite unimportant test task
TODO: 4 marked as done.
usage: todo.sh do ITEM#[, ITEM#, ITEM#, ...]
user@penguin:~/repos/todo.txt-cli$ ./todo.sh do 5 #, 6 #
5 x 2023-01-17 Quite unimportant test task
TODO: 5 marked as done.
x 2023-01-17 Quite unimportant test task
x 2023-01-17 Quite unimportant test task
TODO: /home/user/todo.txt archived.

What is the expected behavior?

As described in the usage.

inkarkat commented 1 year ago

The ITEM# stands for item number; this may be obvious to native speakers, but it's confusing to others (including me at first). Even worse, the usage help indicates multiple item numbers as a comma-separated list (ITEM#[, ITEM#, ITEM#, ...]), but as shell arguments, these have to be separated by whitespace.

So, in order to do items 11, 42, and 99, you'd issue $ todo.sh do 11 42 99. If you include the #, that's the shell's comment prefix, so anything after that is ignored (unless you escape it or leave out the whitespace in front of it).

I'm all for changing the usage, though I'm a bit unsure what to use for item number (vs. the item text itself (which often is represented as the example THING I NEED TO DO text)).

usage: todo.sh do NR [...]
chrysle commented 1 year ago

I'm all for changing the usage, though I'm a bit unsure what to use for item number (vs. the item text itself (which often is represented as the example THING I NEED TO DO text)).

usage: todo.sh do NR [...]

I'd find this more easily understandable:

usage: todo.sh do NR [NR NR...]
chrysle commented 1 year ago

I think other usage messages including the ITEM# and/or commas, like the one of depri, should also be improved. Can I open a PR and implement my suggestion?

inkarkat commented 1 year ago

Yes, sure, go ahead. I agree that this should be done consistently and everywhere.

For the syntax, I'd go with

usage: todo.sh do NR [NR ...]

(So just one repetition of the NR, and a space separating the following ...; incidentally, I've encountered similar syntax today in Python's argparse module, and liked that.