| 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() |