Skip to content

Commit 39b04e8

Browse files
authored
Merge pull request #563 from willcl-ark/fix-init-custom
Improve help when creating new networks
2 parents c3504a5 + 4d40531 commit 39b04e8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/warnet/graph.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import random
3+
import sys
34
from importlib.resources import files
45
from pathlib import Path
56

@@ -36,7 +37,13 @@ def custom_graph(
3637
caddy: bool,
3738
logging: bool,
3839
):
39-
datadir.mkdir(parents=False, exist_ok=False)
40+
try:
41+
datadir.mkdir(parents=False, exist_ok=False)
42+
except FileExistsError as e:
43+
print(e)
44+
print("Exiting network builder without overwriting")
45+
sys.exit(1)
46+
4047
# Generate network.yaml
4148
nodes = []
4249
connections = set()
@@ -211,7 +218,7 @@ def create():
211218
# Check if the project has a networks directory
212219
if not (project_path / "networks").exists():
213220
click.secho(
214-
"The current directory does not have a 'networks' directory. Please run 'warnet init' or 'warnet create' first.",
221+
"The current directory does not have a 'networks' directory. Please run 'warnet init' or 'warnet new' first.",
215222
fg="red",
216223
bold=True,
217224
)

0 commit comments

Comments
 (0)