Add scaffold parent selection: --dir defaults to cwd
This commit is contained in:
@@ -25,3 +25,12 @@ def target_dir(name: str, parent: Path) -> Path:
|
||||
if target.exists():
|
||||
raise ScaffoldError(f"target directory already exists: {target}")
|
||||
return target
|
||||
|
||||
|
||||
def parent_dir(explicit: Path | None) -> Path:
|
||||
"""Return the parent for a new project: *explicit* when given, else cwd."""
|
||||
if explicit is None:
|
||||
return Path.cwd()
|
||||
if not explicit.is_dir():
|
||||
raise ScaffoldError(f"--dir is not an existing directory: {explicit}")
|
||||
return explicit
|
||||
|
||||
Reference in New Issue
Block a user