slab-cli 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- slab_cli/__init__.py +0 -0
- slab_cli/banner.py +92 -0
- slab_cli/client.py +386 -0
- slab_cli/commands/__init__.py +4 -0
- slab_cli/commands/breaks.py +140 -0
- slab_cli/commands/catalog.py +84 -0
- slab_cli/commands/collection.py +676 -0
- slab_cli/commands/custom_sets.py +484 -0
- slab_cli/commands/export.py +129 -0
- slab_cli/commands/lots.py +114 -0
- slab_cli/commands/pricing.py +386 -0
- slab_cli/commands/registry.py +140 -0
- slab_cli/commands/setup.py +24 -0
- slab_cli/config.py +21 -0
- slab_cli/context.py +50 -0
- slab_cli/display.py +1187 -0
- slab_cli/flags.py +189 -0
- slab_cli/help.py +87 -0
- slab_cli/main.py +95 -0
- slab_cli/paging.py +46 -0
- slab_cli/picker.py +78 -0
- slab_cli/prompts.py +549 -0
- slab_cli/sources.py +17 -0
- slab_cli/theme.py +184 -0
- slab_cli-0.1.0.dist-info/METADATA +70 -0
- slab_cli-0.1.0.dist-info/RECORD +28 -0
- slab_cli-0.1.0.dist-info/WHEEL +4 -0
- slab_cli-0.1.0.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""Catalog commands — search cards, browse sets, view card details."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
from slab_schemas.cards import CardSearchQuery, SetSearchQuery
|
|
8
|
+
|
|
9
|
+
from ..context import ctx
|
|
10
|
+
from ..display import console, print_cards, print_sets, render_community_board
|
|
11
|
+
from ..flags import CARD_SEARCH_FLAGS, SET_SEARCH_FLAGS, parse_flags
|
|
12
|
+
from ..picker import pick_card
|
|
13
|
+
from ..prompts import ask_text
|
|
14
|
+
|
|
15
|
+
_UUID_RE = re.compile(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def cmd_search(args: list[str]) -> None:
|
|
19
|
+
"""Search the card catalog by player/set/team, narrowed by the shared filter flags.
|
|
20
|
+
|
|
21
|
+
The same flags work on `slab collection search` — learn them once.
|
|
22
|
+
|
|
23
|
+
Examples:
|
|
24
|
+
slab card search McDavid --rookie
|
|
25
|
+
slab card search Bedard --year 2025 --numbered
|
|
26
|
+
slab card search --brand "Upper Deck" --base --limit 50
|
|
27
|
+
slab card search --team "Minnesota Wild" --auto
|
|
28
|
+
|
|
29
|
+
Sort keys: year, card_number, numbered, subject, brand, set (prefix - for descending).
|
|
30
|
+
"""
|
|
31
|
+
if not args:
|
|
32
|
+
args = [ask_text("Search cards:")]
|
|
33
|
+
|
|
34
|
+
values, q = parse_flags(args, CARD_SEARCH_FLAGS)
|
|
35
|
+
values.setdefault("limit", 25)
|
|
36
|
+
result = ctx.client.search_cards(CardSearchQuery(q=q, **values))
|
|
37
|
+
print_cards(result)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
cmd_search.flags = CARD_SEARCH_FLAGS
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def cmd_sets(args: list[str]) -> None:
|
|
44
|
+
"""Browse sets / products, optionally narrowed by brand, year, or sport.
|
|
45
|
+
|
|
46
|
+
Examples:
|
|
47
|
+
slab set search "sp authentic"
|
|
48
|
+
slab set search --brand "Upper Deck" --year 2025
|
|
49
|
+
"""
|
|
50
|
+
values, q = parse_flags(args, SET_SEARCH_FLAGS)
|
|
51
|
+
values.setdefault("limit", 25)
|
|
52
|
+
result = ctx.client.search_sets(SetSearchQuery(q=q, **values))
|
|
53
|
+
print_sets(result)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
cmd_sets.flags = SET_SEARCH_FLAGS
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def cmd_rainbow(args: list[str]) -> None:
|
|
60
|
+
"""Show every parallel (the 'rainbow') of a card. Pass a full card UUID, or a player name (or
|
|
61
|
+
nothing) to pick one interactively — no need to know the UUID. `get_parallels` resolves the
|
|
62
|
+
slot's base from whatever printing you pick, so the whole rainbow shows regardless of choice."""
|
|
63
|
+
if len(args) == 1 and _UUID_RE.match(args[0]):
|
|
64
|
+
card_uuid = args[0]
|
|
65
|
+
else:
|
|
66
|
+
card = pick_card(" ".join(args) if args else None)
|
|
67
|
+
if card is None:
|
|
68
|
+
return
|
|
69
|
+
card_uuid = card.uuid
|
|
70
|
+
|
|
71
|
+
parallels = ctx.client.get_parallels(card_uuid)
|
|
72
|
+
console.print(f"\n [bold]Rainbow[/bold] ({len(parallels)} variants)\n")
|
|
73
|
+
for c in parallels:
|
|
74
|
+
finish = c.finish or "[bold]Base[/bold]"
|
|
75
|
+
pr = f" /{c.print_run}" if c.print_run else ""
|
|
76
|
+
attrs = f" [{', '.join(a.name for a in c.attributes)}]" if c.attributes else ""
|
|
77
|
+
console.print(f" {finish}{pr}{attrs} [dim]{c.uuid[:8]}[/dim]")
|
|
78
|
+
console.print()
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def cmd_community(args: list[str]) -> None:
|
|
82
|
+
"""The whole community picture — the same page the portal shows: catalog overview, an activity
|
|
83
|
+
ticker, leaderboards (most valuable, most collected, rarest owned), and popular chase sets."""
|
|
84
|
+
render_community_board(ctx.client.get_community_board())
|