manolomartinez / greg

A command-line podcast aggregator
GNU General Public License v3.0
296 stars 37 forks source link

Add basic substring search for `check -f` #80

Closed mandarg closed 1 year ago

mandarg commented 7 years ago

When using greg, I often want to quickly check a feed without bothering to type out its whole name. For example greg check -f philo should get me the closest match for the feed I want ("PhilosophyBites").

Hence, add basic substring matching on lowercased strings to make this happen. This preserves existing functionality (matching on the full name) while adding new functionality (substring search).

Tested this with the example in README, and adding new feeds matching the name. Worked as expected in most cases, with one quirk being that currently it will match on the feed chronologically first by order, rather than the best match (which would be the ideal expectation).

yringot commented 6 years ago

Even better would be to make -f optional because a feed name will almost never start with http://. I suggest this because I find myself frequently typing greg check FEEDNAME only to be told to use either -f or -u. (Kind of like the reason sudo !! exists.)

From my POV it makes sense to make this command a bit smarter. The logic could be like this:

Commandline: greg check STRING (note the missing -f)

if "STRING" starts with http, then assume that it is a URL, otherwise, assume that it is a feed name. check the URL/feed according to the above logic.

If the check fails, print an error like this: You don't appear to have a feed with the name STRING. STRING also does not appear to be a valid URL (be sure to use the full URL, including the http(s) bit)

What do you think? @manolomartinez