Skip to content

Commit 5b75c6c

Browse files
committed
'asgi new' command accepts a name argument
1 parent f6f919b commit 5b75c6c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

piccolo/apps/asgi/commands/new.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,24 @@ def get_server() -> str:
3535
return SERVERS[int(server)]
3636

3737

38-
def new(root: str = "."):
38+
def new(root: str = ".", name: str = "piccolo_project"):
3939
"""
4040
Create a basic ASGI app, including Piccolo, routing, and an admin.
4141
4242
:param root:
4343
Where to create the app e.g. /my/folder. By default it creates the
4444
app in the current directory.
45+
:param name:
46+
The name of the app to create - this will be used to prepopulate things
47+
like the database name.
4548
4649
"""
4750
tree = os.walk(TEMPLATE_DIR)
4851

4952
template_context = {
5053
"router": get_routing_framework(),
5154
"server": get_server(),
55+
"project_identifier": name.replace(" ", "_").lower(),
5256
}
5357

5458
for directory in tree:

piccolo/apps/asgi/commands/templates/starlette/piccolo_conf.py.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from piccolo.conf.apps import AppRegistry
55

66
DB = PostgresEngine(
77
config={
8-
"database": "piccolo_project",
8+
"database": "{{ project_identifier }}",
99
"user": "postgres",
1010
"password": "",
1111
"host": "localhost",

0 commit comments

Comments
 (0)