tldr-pages / tldr-python-client

Python command-line client for tldr pages
https://pypi.org/project/tldr/
MIT License
596 stars 93 forks source link

Add search functionality #173

Closed gotlougit closed 2 years ago

gotlougit commented 2 years ago

This is with reference to issue #172, where I proposed adding a search function to search for a specific subcommand for a given program

For example, searching for how to delete a branch in git can be done using this feature, using the command

tldr git --search "delete branch"

Keep in mind that the very first word you type is the most impactful when trying to decide the most relevant page, the second one less so and so on and so forth.

While the search algorithm I've devised seems to work fairly well, there are some further enhancements I am looking to implement as well:

gotlougit commented 2 years ago

I've made some improvements, like making sure each word has same importance when calculating the score of each page, conforming to the style requirements, and adding a no results found message.

I am looking for more feedback on the search feature since I do want to improve it and also get it into the project.

gotlougit commented 2 years ago

This new commit only searches through cache, but may need some more handling of edge cases (like if someone forcibly deletes the cache directory). However such cases seem to be pretty few and far between, so I think it's fine.