diff --git a/cry/cli.py b/cry/cli.py index 7d8ea51..89860fd 100644 --- a/cry/cli.py +++ b/cry/cli.py @@ -121,7 +121,15 @@ def refresh(url): @cli.command(name="show") @click.argument("pattern", required=False, default="") -def show(pattern): +@click.option( + "--count", + "-c", + type=int, + default=10, + show_default=True, + help="Show at most this many entries from each feed.", +) +def show(pattern, count): """Show feeds and entries. If a pattern is supplied, then filter the feeds to urls or titles that @@ -129,14 +137,14 @@ def show(pattern): """ db = database.Database.local() - feeds = db.load_all(pattern=pattern or "") + feeds = db.load_all(feed_limit=count, pattern=pattern or "") def feed_sort_key(f: feed.Feed) -> int: if len(f.entries) > 0: return max(e.inserted_at for e in f.entries) return -1 - feeds.sort(key=feed_sort_key) + feeds.sort(key=feed_sort_key, reverse=True) for f in feeds: click.echo(f"{f.title}") if len(f.entries) > 0: