From a3c6c8a1ed6d5b1ecbfdc4716fee4bac54de2e94 Mon Sep 17 00:00:00 2001
From: Yaroslav Demidenko <5132376@mail.ru>
Date: Tue, 16 Nov 2021 12:54:58 +0300
Subject: [PATCH] Added quite arg for features (#49)

* Added quite arg for features

Co-authored-by: Pavel Kirilin <win10@list.ru>
---
 README.md                       | 2 ++
 fastapi_template/cli.py         | 9 ++++++++-
 fastapi_template/input_model.py | 1 +
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 6f25a02..74a5db7 100644
--- a/README.md
+++ b/README.md
@@ -71,6 +71,7 @@ usage: FastAPI template [-h] [--version] [--name PROJECT_NAME]
                         [--orm {ormar,sqlalchemy,tortoise}]
                         [--ci {none,gitlab,github}] [--redis] [--migrations]
                         [--kube] [--dummy] [--routers] [--swagger] [--force]
+                        [--quite]
 
 optional arguments:
   -h, --help            show this help message and exit
@@ -92,4 +93,5 @@ optional arguments:
   --routers             Add exmaple routers
   --swagger             Eanble self-hosted swagger
   --force               Owerrite directory if it exists
+  --quite               Do not ask for feature during generation
 ```
diff --git a/fastapi_template/cli.py b/fastapi_template/cli.py
index b0933e1..54f8930 100644
--- a/fastapi_template/cli.py
+++ b/fastapi_template/cli.py
@@ -118,6 +118,13 @@ def parse_args():
         default=False,
         dest="force",
     )
+    parser.add_argument(
+        "--quite",
+        help="Do not ask for feature during generation",
+        action="store_true",
+        default=False,
+        dest="quite",
+    )
 
     return parser.parse_args()
 
@@ -155,7 +162,7 @@ def ask_features(current_context: BuilderContext) -> BuilderContext:
         if feature["value"] is None:
             setattr(current_context, feature["name"], False)
             checkbox_values.append((feature["name"], feature_name))
-    if checkbox_values:
+    if checkbox_values and not current_context.quite:
         results = checkboxlist_dialog(
             title="Features",
             text="What features do you wanna add?",
diff --git a/fastapi_template/input_model.py b/fastapi_template/input_model.py
index 9a35b8f..be45077 100644
--- a/fastapi_template/input_model.py
+++ b/fastapi_template/input_model.py
@@ -87,6 +87,7 @@ class BuilderContext(BaseModel):
     add_dummy: Optional[bool] = False
     self_hosted_swagger: Optional[bool]
     force: bool = False
+    quite: bool = False
 
     class Config:
         orm_mode = True
-- 
GitLab