This commit is contained in:
2024-01-10 12:58:45 +05:00
parent 75a14dba1d
commit af0f09bab8
4 changed files with 40 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
{
"project_slug": "sample",
"foo": "bar"
"use_database": true,
"use_cache": true
}

View File

@@ -1,8 +1,14 @@
print("{{cookiecutter.project_slug}}")
{% if cookiecutter.foo == "bar" %}
print("{{cookiecutter.foo}}")
{% if cookiecutter.use_database %}
print("Framework will use database")
{% else %}
# print("{{cookiecutter.foo}}")
print("Framework will not use database")
{% endif %}
{% if cookiecutter.use_cache %}
print("Framework will use cache")
{% else %}
print("Framework will not use cache")
{% endif %}

32
main.py
View File

@@ -1,6 +1,30 @@
import typer
from cookiecutter.main import cookiecutter
cookiecutter("cookiecutter-test",
# directory=".",
extra_context={"foo": "quz"},
output_dir="test_output")
# cookiecutter("cookiecutter-test",
# # directory=".",
# extra_context={"foo": "quz"},
# output_dir="test_output")
app = typer.Typer()
@app.command()
def create_project(project_name: str,
template: str = "cookiecutter-test",
output_dir: str = ".",
use_database: bool = True,
use_cache: bool = True,
):
typer.echo(f"Creating project {project_name}")
cookiecutter(template,
extra_context={
"use_database": use_database,
"use_cache": use_cache,
},
output_dir=output_dir)
if __name__ == "__main__":
app()

View File

@@ -1 +1,2 @@
cookiecutter==2.5.0
typer==0.9.0