mirror of
https://github.com/ihabunek/toot.git
synced 2025-06-30 22:18:36 -04:00
Improve search option types
This commit is contained in:
parent
71d9c9ff12
commit
803f36d1ed
@ -558,8 +558,8 @@ def search(app, user, query, resolve=False, type=None, offset=None, limit=None):
|
||||
"q": query,
|
||||
"resolve": str_bool(resolve),
|
||||
"type": type,
|
||||
"offset": int(offset) if offset else None,
|
||||
"limit": int(limit) if limit else None
|
||||
"offset": offset,
|
||||
"limit": limit,
|
||||
})
|
||||
|
||||
return http.get(app, user, "/api/v2/search", params)
|
||||
|
@ -75,15 +75,25 @@ def instance(instance: Optional[str], json: bool):
|
||||
@cli.command()
|
||||
@click.argument("query")
|
||||
@click.option("-r", "--resolve", is_flag=True, help="Resolve non-local accounts")
|
||||
@click.option("-t", "--type", help="Type of search (accounts, hashtags, statuses)")
|
||||
@click.option("-o", "--offset", help="Return results starting from (default 0)")
|
||||
@click.option("-l", "--limit", help="Maximum number of results (default 20, max 40)")
|
||||
@click.option(
|
||||
"-t", "--type",
|
||||
type=click.Choice(["accounts", "hashtags", "statuses"]),
|
||||
help="Limit search to one type only"
|
||||
)
|
||||
@click.option("-o", "--offset", type=int, help="Return results starting from (default 0)")
|
||||
@click.option("-l", "--limit", type=int, help="Maximum number of results to return, per type. (default 20, max 40)")
|
||||
@json_option
|
||||
@pass_context
|
||||
def search(ctx: Context, query: str, resolve: bool,
|
||||
type: Optional[str], offset: Optional[int], limit: Optional[int],
|
||||
json: bool):
|
||||
"""Search for users or hashtags"""
|
||||
def search(
|
||||
ctx: Context,
|
||||
query: str,
|
||||
resolve: bool,
|
||||
type: Optional[str],
|
||||
offset: Optional[int],
|
||||
limit: Optional[int],
|
||||
json: bool
|
||||
):
|
||||
"""Search for content in accounts, statuses and hashtags."""
|
||||
response = api.search(ctx.app, ctx.user, query, resolve, type, offset, limit)
|
||||
if json:
|
||||
click.echo(response.text)
|
||||
|
Loading…
x
Reference in New Issue
Block a user