Skip to content

Commit 4a6d931

Browse files
Add self-healing path recovery to CLI
1 parent f1ce670 commit 4a6d931

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

pythoncms/cli.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,19 @@ def start(name, run):
4444
try:
4545
current_dir = Path.cwd()
4646
except FileNotFoundError:
47-
click.echo("Error: The current working directory does not exist. Please change to a valid directory.")
48-
return
47+
# Self-healing: if directory was deleted and recreated, try to recover from PWD env
48+
pwd = os.environ.get("PWD")
49+
if pwd and os.path.exists(pwd):
50+
current_dir = Path(pwd)
51+
else:
52+
click.echo(
53+
"Error: Your current directory has been deleted. Please 'cd' out and back in."
54+
)
55+
return
4956

5057
dest = os.path.join(str(current_dir), name)
5158

59+
5260
if os.path.exists(dest):
5361
click.echo(f"Error: Directory {name} already exists.")
5462
return

0 commit comments

Comments
 (0)