Skip to content
Merged

Git #12

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
14 changes: 13 additions & 1 deletion pyml_cli/cli/project.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""Project initialization CLI."""

import os
from pathlib import Path

from cookiecutter.main import cookiecutter
from loguru import logger
from sh import git
from typer import Typer

app = Typer()
Expand All @@ -13,4 +16,13 @@
@app.command()
def init():
"""Initialize project from template."""
cookiecutter(str(PROJECT_TEMPLATE_DIR.resolve()))
output_dir = cookiecutter(str(PROJECT_TEMPLATE_DIR.resolve()))

if output_dir:
project_path = Path(output_dir)
try:
os.chdir(project_path)
git("init", "-b", "main")
logger.info(f"✓ Initialized git repository in {project_path}")
except Exception as e:
print(f"⚠ Git initialization failed: {e} - skipping git initialization")
Loading