#!/usr/bin/env python3
"""Small local prompt fixture. Run in an empty directory; requires Python 3."""
import json
from pathlib import Path
import re


def main():
    project = input("Project name: ").strip()
    if not re.fullmatch(r"[a-z][a-z0-9-]{0,39}", project):
        raise SystemExit("Use a lowercase project name, up to 40 characters.")
    answer = input("Create local configuration? [y/n]: ").strip().lower()
    if answer != "y":
        print("Cancelled. No file written.")
        return
    target = Path(f"{project}-config.json")
    # Refuse to replace existing work, making repeated evaluations explicit.
    with target.open("x", encoding="utf-8") as output:
        json.dump({"project": project, "enabled": True}, output, indent=2)
        output.write("\n")
    print(f"Wrote {target}")


if __name__ == "__main__":
    main()
