repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

opencode/skills/presenterm/scripts/new-presentation.py

Raw
File outline
#!/usr/bin/env python3
"""
Generate a presenterm presentation template.

Usage:
  python new-presentation.py --title "My Talk" --author "Me" --theme dark --template minimal --output slides.md
  python new-presentation.py --title "My Talk" --author "Me" --theme catppuccin-mocha --template tech-talk --output slides.md
  python new-presentation.py --title "X" --author "Y" --output -  # write to stdout
"""

import argparse
import sys
from pathlib import Path

TEMPLATES = {
    "minimal": """---
title: "{title}"
author: "{author}"
theme:
  name: {theme}
---

First Slide
===

Your content here.

<!-- end_slide -->

Second Slide
===

More content.

<!-- end_slide -->
""",
    "tech-talk": """---
title: "{title}"
author: "{author}"
theme:
  name: {theme}
---

<!-- speaker_note: THE BIG WHY - hook the audience immediately -->

Why This Matters
===

[Establish motivation in 2-3 sentences]

<!-- end_slide -->

The Problem
===

[Describe the pain point]

<!-- incremental_lists: true -->

* Point 1
* Point 2
* Point 3

<!-- incremental_lists: false -->

<!-- end_slide -->

The Solution
===

[Your approach]

<!-- end_slide -->

<!-- jump_to_middle -->

Demo
===

[Live code or screenshots]

<!-- end_slide -->

Summary
===

[Key takeaways]

**Questions?**
""",
}

VALID_THEMES = [
    "catppuccin-latte",
    "catppuccin-frappe",
    "catppuccin-macchiato",
    "catppuccin-mocha",
    "dark",
    "gruvbox-dark",
    "light",
    "terminal-dark",
    "terminal-light",
    "tokyonight-day",
    "tokyonight-moon",
    "tokyonight-night",
    "tokyonight-storm",
]


def main():
    parser = argparse.ArgumentParser(
        description="Generate a presenterm presentation template",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog="""
Examples:
  python new-presentation.py --title "My Talk" --author "Me" --output slides.md
  python new-presentation.py --title "My Talk" --author "Me" --theme catppuccin-mocha --template tech-talk --output slides.md
  python new-presentation.py --title "My Talk" --author "Me" --output -  # stdout

Available themes:
  catppuccin-latte, catppuccin-frappe, catppuccin-macchiato, catppuccin-mocha
  dark, light, gruvbox-dark
  terminal-dark, terminal-light
  tokyonight-day, tokyonight-moon, tokyonight-night, tokyonight-storm

Available templates:
  minimal   - Bare starter (2 placeholder slides)
  tech-talk - Narrative arc structure (Why → Problem → Solution → Demo → Summary)
""",
    )
    parser.add_argument(
        "--title",
        help="Presentation title",
    )
    parser.add_argument(
        "--author",
        help="Author name",
    )
    parser.add_argument(
        "--theme",
        default="dark",
        help=f"Theme name (default: dark). Use --list-themes to see options.",
    )
    parser.add_argument(
        "--template",
        choices=list(TEMPLATES.keys()),
        default="minimal",
        help="Template to use (default: minimal)",
    )
    parser.add_argument(
        "--output",
        default="-",
        help="Output file path. Use - for stdout (default: -)",
    )
    parser.add_argument(
        "--list-themes",
        action="store_true",
        help="List available themes and exit",
    )

    args = parser.parse_args()

    if args.list_themes:
        print("Available themes:")
        for theme in VALID_THEMES:
            print(f"  {theme}")
        return 0

    if not args.title or not args.author:
        print(
            "Error: --title and --author are required",
            file=sys.stderr,
        )
        return 1

    if args.theme not in VALID_THEMES:
        print(
            f"Error: Unknown theme '{args.theme}'",
            file=sys.stderr,
        )
        print("Use --list-themes to see available themes.", file=sys.stderr)
        return 1

    content = TEMPLATES[args.template].format(
        title=args.title,
        author=args.author,
        theme=args.theme,
    )

    if args.output == "-":
        print(content)
    else:
        output_path = Path(args.output)
        output_path.parent.mkdir(parents=True, exist_ok=True)
        output_path.write_text(content)
        print(f"Created: {args.output}")

    return 0


if __name__ == "__main__":
    sys.exit(main())