-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgenerate-demo.py
More file actions
44 lines (35 loc) · 1.05 KB
/
generate-demo.py
File metadata and controls
44 lines (35 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "cookiecutter",
# "cruft",
# "python-dotenv",
# "typer",
# ]
# ///
"""Python script for generating a demo project."""
import sys
from pathlib import Path
from typing import Annotated
import typer
from util import FolderOption
from util import generate_demo
cli: typer.Typer = typer.Typer()
@cli.callback(invoke_without_command=True)
def main(
demos_cache_folder: Annotated[Path, FolderOption("--demos-cache-folder", "-c")],
add_rust_extension: Annotated[bool, typer.Option("--add-rust-extension", "-r")] = False,
no_cache: Annotated[bool, typer.Option("--no-cache", "-n")] = False
) -> None:
"""Generates a project demo using the cookiecutter-robust-python template."""
try:
generate_demo(
demos_cache_folder=demos_cache_folder,
add_rust_extension=add_rust_extension,
no_cache=no_cache
)
except Exception as error:
typer.secho(f"error: {error}", fg="red")
sys.exit(1)
if __name__ == "__main__":
cli()