This commit is contained in:
Jared Whiklo 2026-01-13 10:51:49 -06:00 committed by GitHub
commit 40267edcc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -63,6 +63,23 @@ class Command(BaseCommand):
default=False,
help="Delete templates after syncing",
)
group = parser.add_mutually_exclusive_group()
group.add_argument(
"-y",
"--yes",
action="store_true",
dest="auto_answer",
default=None,
help="Answer yes to all template creation questions."
)
group.add_argument(
"-n",
"--no",
action="store_false",
dest="auto_answer",
default=None,
help="Answer no to all template creation questions."
)
def handle(self, **options):
extension = options.get("ext")
@ -70,6 +87,7 @@ class Command(BaseCommand):
overwrite = options.get("overwrite")
app_first = options.get("app_first")
delete = options.get("delete")
auto_answer = options.get('auto_answer')
if not extension.startswith("."):
extension = f".{extension}"
@ -103,12 +121,15 @@ class Command(BaseCommand):
t = Template.on_site.get(name__exact=name)
except Template.DoesNotExist:
if not force:
confirm = input(
"\nA '%s' template doesn't exist in the "
"database.\nCreate it with '%s'?"
" (y/[n]): "
"" % (name, path)
)
if auto_answer is not None:
confirm = "y" if auto_answer else "n"
else:
confirm = input(
"\nA '%s' template doesn't exist in the "
"database.\nCreate it with '%s'?"
" (y/[n]): "
"" % (name, path)
)
if force or confirm.lower().startswith("y"):
with open(path, encoding="utf-8") as f:
t = Template(name=name, content=f.read())