-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathguests.py
More file actions
56 lines (41 loc) · 1.28 KB
/
guests.py
File metadata and controls
56 lines (41 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""Guest commands — search, get, list."""
from __future__ import annotations
import cyclopts
from talk_python_cli.formatting import display
guests_app = cyclopts.App(
name='guests',
help='Browse and search Talk Python to Me podcast guests.',
)
def _client():
from talk_python_cli.app import get_client
return get_client()
@guests_app.command
def search(query: str, *, limit: int = 10) -> None:
"""Search guests by name.
Parameters
----------
query
Guest name or partial name to search for.
limit
Maximum number of results to return.
"""
client = _client()
content = client.call_tool('search_guests', {'query': query, 'limit': limit})
display(content, client.output_format)
@guests_app.command
def get(guest_id: int) -> None:
"""Get detailed info about a guest by their ID.
Parameters
----------
guest_id
The guest ID.
"""
client = _client()
content = client.call_tool('get_guest_by_id', {'guest_id': guest_id})
display(content, client.output_format)
@guests_app.command(name='list')
def list_guests() -> None:
"""List all podcast guests, sorted by number of appearances."""
client = _client()
content = client.call_tool('get_guests')
display(content, client.output_format)