Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support searching for toots #475

Open
michaelgruenewald opened this issue Mar 17, 2024 · 0 comments
Open

Support searching for toots #475

michaelgruenewald opened this issue Mar 17, 2024 · 0 comments

Comments

@michaelgruenewald
Copy link

Recent versions of Mastodon also returns toots/statuses in the search results. toot currently ignores them and shows a 'Nothing found' message instead.

Supporting that should be fairly straight-forward; the results are already visible when using --json. I prototyped this, which works for me:

diff --git a/toot/output.py b/toot/output.py
index 88f65ed..fa4ebd6 100644
--- a/toot/output.py
+++ b/toot/output.py
@@ -4,7 +4,7 @@ import shutil
 import textwrap
 import typing as t
 
-from toot.entities import Account, Instance, Notification, Poll, Status, List
+from toot.entities import Account, Instance, Notification, Poll, Status, List, from_dict
 from toot.utils import get_text, html_to_paragraphs
 from toot.wcstring import wc_wrap
 from wcwidth import wcswidth
@@ -156,6 +156,7 @@ def print_list_accounts(accounts):
 def print_search_results(results):
     accounts = results["accounts"]
     hashtags = results["hashtags"]
+    statuses = results["statuses"]
 
     if accounts:
         click.echo("\nAccounts:")
@@ -165,7 +166,10 @@ def print_search_results(results):
         click.echo("\nHashtags:")
         click.echo(", ".join([format_tag_name(tag) for tag in hashtags]))
 
-    if not accounts and not hashtags:
+    if statuses:
+        print_timeline(from_dict(Status, s) for s in statuses)
+
+    if not accounts and not hashtags and not statuses:
         click.echo("Nothing found")

I can make a proper PR, but I'm not sure whether that's the best way of implementing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant