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
7 changes: 7 additions & 0 deletions concore_cli/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,14 @@ def _build_graphml(project_name, selected_langs):
# ---------------------------------------------------------------------------


def _check_project_name(name):
if name in (".", "..") or Path(name).name != name:
raise ValueError("Project name must not contain path separators")


def init_project_interactive(name, selected_langs, console):
"""Create a project with one node per selected language (no edges)."""
_check_project_name(name)
project_path = Path(name)

if project_path.exists():
Expand Down Expand Up @@ -327,6 +333,7 @@ def init_project_interactive(name, selected_langs, console):

def init_project(name, template, console):
"""Non-interactive init — single Python node skeleton."""
_check_project_name(name)
project_path = Path(name)

if project_path.exists():
Expand Down
9 changes: 9 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ def test_init_existing_directory(self):
self.assertNotEqual(result.exit_code, 0)
self.assertIn("already exists", result.output)

def test_init_rejects_path_in_name(self):
with self.runner.isolated_filesystem(temp_dir=self.temp_dir):
Path("work").mkdir()
os.chdir("work")
result = self.runner.invoke(cli, ["init", "../x"])
self.assertNotEqual(result.exit_code, 0)
self.assertIn("path separators", result.output)
self.assertFalse(Path("../x").exists())

def test_validate_missing_file(self):
result = self.runner.invoke(cli, ["validate", "nonexistent.graphml"])
self.assertNotEqual(result.exit_code, 0)
Expand Down
Loading