Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os

def create_project(project_name):
"""Creates a new project folder with starter files (README.md and main.py).
If the folder already exists, prints a massage instead of crashing."""
try:
os.makedirs(project_name)
print(f"Created project folder: {project_name}")

with open(os.path.join(project_name, "README.md"), "w") as f:
f.write(f"# {project_name}\n")

with open(os.path.join(project_name, "main.py"), "w") as f:
f.write("print('Hello from your new project!')\n")

print("Starter files generated.")

except FileExistsError:
print(f"A project named '{project_name}' already exists. Choose a different name.")
1 change: 1 addition & 0 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

from templates import list_templates
from generator import create_project

def main():
print("🚀 Welcome to Create Forge App")
Expand Down