habito
habito copied to clipboard
Checkin with id
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!
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).
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.
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.
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?
Let's go for simple, i.e. no named options. We will support it later if needed.