Skip to content

Commit ee149fa

Browse files
committed
refactor: extract interactive GIF generation into separate script
1 parent 263d50e commit ee149fa

File tree

2 files changed

+39
-32
lines changed

2 files changed

+39
-32
lines changed

scripts/gen_cli_help_screenshots.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,37 +37,5 @@ def _export_cmd_as_svg(cmd: str, file_path: Path) -> None:
3737
print("Saved to:", file_path.as_posix())
3838

3939

40-
def gen_interactive_screenshots() -> None:
41-
"""Generate GIF screenshots for interactive commands using VHS."""
42-
images_root = Path(__file__).parent.parent / "docs" / "images"
43-
44-
vhs_files = ["init.tape", "commit.tape"]
45-
46-
for vhs_file in vhs_files:
47-
vhs_path = images_root / vhs_file
48-
if vhs_path.exists():
49-
print(f"Processing VHS file: {vhs_file}")
50-
try:
51-
subprocess.run(
52-
["vhs", str(vhs_path)],
53-
check=True,
54-
cwd=images_root.as_posix(),
55-
)
56-
gif_file = vhs_file.replace(".tape", ".gif")
57-
print(f"✓ Generated {gif_file} from {vhs_file}")
58-
except subprocess.CalledProcessError as e:
59-
print(f"✗ Error processing {vhs_file}: {e}")
60-
raise
61-
except FileNotFoundError:
62-
print(
63-
"VHS is not installed. Please install it from: "
64-
"https://github.com/charmbracelet/vhs"
65-
)
66-
raise
67-
else:
68-
print(f"Warning: {vhs_file} not found, skipping")
69-
70-
7140
if __name__ == "__main__":
7241
gen_cli_help_screenshots()
73-
gen_interactive_screenshots()
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import subprocess
2+
from pathlib import Path
3+
4+
5+
def gen_cli_interactive_gifs() -> None:
6+
"""Generate GIF screenshots for interactive commands using VHS."""
7+
vhs_dir = Path(__file__).parent.parent / "docs" / "images"
8+
output_dir = Path(__file__).parent.parent / "docs" / "images" / "cli_interactive"
9+
output_dir.mkdir(parents=True, exist_ok=True)
10+
11+
vhs_files = list(vhs_dir.glob("*.tape"))
12+
13+
if not vhs_files:
14+
print("No VHS tape files found in docs/images/, skipping")
15+
return
16+
17+
for vhs_file in vhs_files:
18+
print(f"Processing: {vhs_file.name}")
19+
try:
20+
subprocess.run(
21+
["vhs", vhs_file.name],
22+
check=True,
23+
cwd=vhs_dir,
24+
)
25+
gif_name = vhs_file.stem + ".gif"
26+
print(f"✓ Generated {gif_name}")
27+
except FileNotFoundError:
28+
print(
29+
"✗ VHS is not installed. Please install it from: "
30+
"https://github.com/charmbracelet/vhs"
31+
)
32+
raise
33+
except subprocess.CalledProcessError as e:
34+
print(f"✗ Error processing {vhs_file.name}: {e}")
35+
raise
36+
37+
38+
if __name__ == "__main__":
39+
gen_cli_interactive_gifs()

0 commit comments

Comments
 (0)