added better documentation

This commit is contained in:
Falko Victor Habel 2024-05-20 13:24:27 +02:00
parent 953342c280
commit 52310a9021
1 changed files with 12 additions and 5 deletions

View File

@ -19,18 +19,21 @@ def main():
args = parser.parse_args()
config = read_config()
# If no config file exists and user does not go into "config mode"
if config is None and args.config is False:
sys.exit("No Config available. please run: 'python project.py --config' to set it up")
# add config
elif args.config is True:
config = configure()
write_config(config)
# change ui mode
elif args.m:
config = handle_change_mode(args)
write_config(config)
# start terminal ui
elif config["mode"] == "terminal":
handle_terminal(args)
# start customtkinter ui
elif config["mode"] == "gui":
# start gui
try:
@ -70,9 +73,13 @@ def read_config():
with open(CONFIG_FILE, "r") as f:
return json.load(f)
def write_config(config: dict):
try:
with open(CONFIG_FILE, "w") as config_file:
json.dump(config, config_file, indent=4)
except FileNotFoundError:
sys.exit(ERROR_CORRPUTED_CONFIG)
def handle_change_mode(args):
config = read_config()
@ -88,7 +95,7 @@ def handle_change_mode(args):
def handle_terminal(args):
config = read_config()
# if a prompt exists
if args.p:
try:
bot = TerminalBot(args.p, args.f, **config["ollamaConfig"])