mjpost / bibsearch

Download, manage, and search a BibTeX database.
Other
64 stars 5 forks source link

open and edit should work only on cache #29

Open mjpost opened 6 years ago

mjpost commented 6 years ago

The semantics of open and edit are a bit strange internally. You either open something from the cache, or search for something new, and open / edit it if the search returns only one result. I suggest instead that open and edit work only on the cache. If you want to open or edit something, you first search for it, then call open or edit with the indexed result.

We could also add -e (edit) and -o (open) flags to "search", which would edit / open the results iff len(results) == 1.

davvil commented 6 years ago

Actually the semantics is consistent among all commands that operate on the DB (search, open, edit, download, delete) and are all implemented in the same way (arxiv is a bit different). E.g. you can do bibsearch search and it will repeat the last search. open is a bit special in that it requires that the search returns only one entry, but the rest (edit included!) do not pose any additional restrictions.

I do not see the advantage in limiting the mode of operation for open and edit, neither in terms of user experience (the commands without arguments already work) nor in terms of code quality/clarity.

No defined opinion about the -e and -o flags for search. I don't think I would use then, but I don't have any strong feelings against them.

davvil commented 6 years ago

Oh, I see now that you changed the code and edit and open have their own search functions. Couldn't the indexing logic be included in BibDB.search(). We can use the heuristic that if the query is just a number, then an index in the previous search is meant.