Skip to content

Commit

Permalink
Added prompt and overwrite to setup/__main__.py (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
chughes741 authored Aug 5, 2023
1 parent 8e015d5 commit 136b1e4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion openct/setup/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
"""Config file generator."""

import os

import yaml

CONFIG_FILE = "config.yml"

if os.path.exists(CONFIG_FILE):
user_input = input(
f"The config file '{CONFIG_FILE}' already exists. Do you want to overwrite it? (yes/no): "
).lower()
if user_input != "yes" and user_input != "y":
print("Config file not overwritten. Exiting.")
exit()

mt_backup_config = {
"identity": {
Expand All @@ -21,5 +32,5 @@
},
}

with open(file="config.yml", mode="a", encoding="utf-8") as file:
with open(file=CONFIG_FILE, mode="w", encoding="utf-8") as file:
yaml.dump(mt_backup_config, file, default_flow_style=False)

0 comments on commit 136b1e4

Please sign in to comment.