From 6797d94ccd4e8870d908c624db7872e54e337b48 Mon Sep 17 00:00:00 2001 From: Piotr Date: Sun, 26 May 2024 22:45:01 +0200 Subject: [PATCH] feat: add safeguard against overriding existing file Signed-off-by: Piotr --- killercoda_cli/cli.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/killercoda_cli/cli.py b/killercoda_cli/cli.py index ce80038..c85847f 100755 --- a/killercoda_cli/cli.py +++ b/killercoda_cli/cli.py @@ -368,8 +368,13 @@ def execute_file_operations(file_operations): os.chmod(operation.path, operation.mode) elif operation.operation == "rename": os.rename(operation.path, operation.content) + def init_project(): - """initialize a new project by creting index.json file""" + """initialize a new project by creating index.json file""" + if os.path.exists("index.json"): + print("The 'index.json' file already exists. Please edit the existing file.") + return + index_data = { "details": { "title": "Project Title",