habito icon indicating copy to clipboard operation
habito copied to clipboard

Checkin with id

Open Ben-Baert opened this issue 8 years ago • 5 comments

I think it would be cleaner (both the code and the actual usage of the application) to allow checkins by id rather than name matching. This is likely how it would be used in practice anyway. If you type habito list, you see the list of habits with their id, then it's very easy to checkin by id. This would also be consistent with the edit and delete commands (if you choose to accept them).

Any thoughts, suggestions are definitely welcome!

Ben-Baert avatar May 19 '16 23:05 Ben-Baert

Using id will force user to do a habito list first, likely they won't remember the id to name mapping for each habit :) Name is more usable as user knows what he wants to checkin. Current names match works with partial strings to reduce typing effort.

There's a possibility of ambiguity with names though. In future we can fix that with some kind of interactive input (may be with inquirer or qprompt).

codito avatar May 20 '16 02:05 codito

I personally always use habito list, but this may be a consequence of using todo.txt a lot, which also uses id matching. Of course, todo.txt is a different kind of application, but I guess it's just a habit (no pun intended). I alias common commands (i.e. habito list is hl on my computer), so it's very quick.

I would propose making a separate function that either takes a name or an id. Id match will either match or say there's no match, name matching will look for an item that matches, if multiple matches it will list the possibilities and the user can pick the right one. Something like:

your input matches multiple items:
1. item one
2. item two

Which one do you mean (type in the number to continue)?

This caters to both the 'id users' and the 'name users', so to speak, and it also reduces the name ambiguity you mentioned.

Abstracting this into a separate function means it can be used in checkins, edits, deletes and potential future features.

Ben-Baert avatar May 20 '16 11:05 Ben-Baert

The user is just going to use habito checkin 1 -q 10 or habito checkin run -q 10 both will resolve to the habit entry 1: run 10miles a day and update it. Or are you proposing named options: -i 1 for id for instance?

Separate function will be good.

codito avatar May 22 '16 02:05 codito

Both options are possible. It's possible to check whether the argument is an int and if so, try to get by id, else get by name or simply HabitModel.select().where(HabitModel.id == user_input | HabitModel.name == user_input). The named options are fine by me too. I don't have any preference either way; I don't thin it will matter much either way. Any thoughts/preferences?

Ben-Baert avatar May 22 '16 10:05 Ben-Baert

Let's go for simple, i.e. no named options. We will support it later if needed.

codito avatar May 23 '16 14:05 codito