diff --git a/src/noot/cli.py b/src/noot/cli.py index 861a424..5e708d5 100644 --- a/src/noot/cli.py +++ b/src/noot/cli.py @@ -46,6 +46,7 @@ def cmd_init(args): msg = f"[bold green]Project '{project_name}' initialized![/bold green]" console.print(f"\n{msg}") console.print("\n[dim]Created:[/dim]") + console.print(" .git/") console.print(f" src/{project_name}/__init__.py") console.print(f" cli/{project_name}.py") console.print(f" tests/test_{project_name}.py") diff --git a/src/noot/init.py b/src/noot/init.py index c2f6b3e..f902561 100644 --- a/src/noot/init.py +++ b/src/noot/init.py @@ -1,5 +1,6 @@ """Project initialization for noot.""" +import subprocess from pathlib import Path @@ -8,6 +9,7 @@ def init_project(target_dir: Path, project_name: str) -> None: Initialize a noot project in the target directory. Creates: + - .git/ (git repository) - pyproject.toml (project configuration) - src/{project_name}/__init__.py (package) - cli/{project_name}.py (sample CLI) @@ -50,6 +52,9 @@ def init_project(target_dir: Path, project_name: str) -> None: "Package may be incorrectly installed." ) + # Initialize git repository + subprocess.run(["git", "init"], cwd=target_dir, check=True, capture_output=True) + # Create directory structure (target_dir / "src" / project_name).mkdir(parents=True, exist_ok=True) (target_dir / "cli").mkdir(exist_ok=True) diff --git a/tests/test_init_command.py b/tests/test_init_command.py index ee29940..6300fab 100644 --- a/tests/test_init_command.py +++ b/tests/test_init_command.py @@ -22,6 +22,9 @@ def test_init_command_creates_project(): assert result.returncode == 0, f"Command failed: {result.stderr}" assert "initialized" in result.stdout.lower() + # Verify git repository initialized + assert (tmpdir / ".git").is_dir() + # Verify pyproject.toml at root assert (tmpdir / "pyproject.toml").exists()