From af0f09bab8b5b3e278075b94e19581bb293066e4 Mon Sep 17 00:00:00 2001 From: Shnaider Pavel Date: Wed, 10 Jan 2024 12:58:45 +0500 Subject: [PATCH] Test 2 --- cookiecutter-test/cookiecutter.json | 3 +- .../{{cookiecutter.project_slug}}/main.py | 12 +++++-- main.py | 32 ++++++++++++++++--- req.txt | 1 + 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/cookiecutter-test/cookiecutter.json b/cookiecutter-test/cookiecutter.json index d409c52..02ec7cb 100644 --- a/cookiecutter-test/cookiecutter.json +++ b/cookiecutter-test/cookiecutter.json @@ -1,4 +1,5 @@ { "project_slug": "sample", - "foo": "bar" + "use_database": true, + "use_cache": true } diff --git a/cookiecutter-test/{{cookiecutter.project_slug}}/main.py b/cookiecutter-test/{{cookiecutter.project_slug}}/main.py index 872af4e..d7964c7 100644 --- a/cookiecutter-test/{{cookiecutter.project_slug}}/main.py +++ b/cookiecutter-test/{{cookiecutter.project_slug}}/main.py @@ -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 %} diff --git a/main.py b/main.py index bafd7d2..1c553d0 100644 --- a/main.py +++ b/main.py @@ -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() diff --git a/req.txt b/req.txt index b5ae616..9fdbbb9 100644 --- a/req.txt +++ b/req.txt @@ -1 +1,2 @@ cookiecutter==2.5.0 +typer==0.9.0