Skip to content

Commit 9f04eec

Browse files
committed
fix: extract border label and fix formatting
1 parent cd571c0 commit 9f04eec

3 files changed

Lines changed: 24 additions & 11 deletions

File tree

apick.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ def pick_endpoint(endpoints: list[dict], spec: dict, script_path: str) -> dict |
245245
json.dump(spec, spec_file)
246246
spec_file_name = spec_file.name
247247

248+
api_title = spec.get("info", {}).get("title")
249+
border_label = f" apick — {api_title} " if api_title else " apick "
250+
248251
try:
249252
preview_cmd = (
250253
f"{sys.executable} {script_path} --_preview {{1}} --_spec-file {spec_file_name}"
@@ -255,11 +258,16 @@ def pick_endpoint(endpoints: list[dict], spec: dict, script_path: str) -> dict |
255258
"fzf",
256259
"--ansi",
257260
"--reverse",
258-
"--nth", "2..",
259-
"--with-nth", "2..",
260-
"--border", "rounded",
261-
"--border-label", " apick ",
262-
"--pointer", "▶",
261+
"--nth",
262+
"2..",
263+
"--with-nth",
264+
"2..",
265+
"--border",
266+
"rounded",
267+
"--border-label",
268+
border_label,
269+
"--pointer",
270+
"▶",
263271
"--header",
264272
"Select an endpoint (type to search)",
265273
"--preview",
@@ -525,11 +533,16 @@ def pick_history_entry(entries: list[dict]) -> dict | None:
525533
"fzf",
526534
"--ansi",
527535
"--reverse",
528-
"--nth", "2..",
529-
"--with-nth", "2..",
530-
"--border", "rounded",
531-
"--border-label", " history ",
532-
"--pointer", "▶",
536+
"--nth",
537+
"2..",
538+
"--with-nth",
539+
"2..",
540+
"--border",
541+
"rounded",
542+
"--border-label",
543+
" history ",
544+
"--pointer",
545+
"▶",
533546
"--header",
534547
"Select a request to replay (type to search)",
535548
"--preview",

demo.gif

376 KB
Loading

demo.tape

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Set WindowBarSize 40
1616
Sleep 500ms
1717

1818
# Launch apick with the Petstore OpenAPI spec
19-
Type "apick https://petstore3.swagger.io/api/v3/openapi.json"
19+
Type "uv run apick https://petstore3.swagger.io/api/v3/openapi.json"
2020
Sleep 300ms
2121
Enter
2222

0 commit comments

Comments
 (0)