From 40875864491d89ae3553cce61fee11aaefda0850 Mon Sep 17 00:00:00 2001 From: kingbri Date: Sun, 26 May 2024 21:37:52 -0400 Subject: [PATCH] Start: Create config.yml if it doesn't exist While TabbyAPI doesn't need a config.yml to run, new users can get confused by the task of copying config_sample.yml to config.yml. Therefore, automatically do this in the start script to immediately expose options to the user. Signed-off-by: kingbri --- start.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/start.py b/start.py index 6e4f792..d1f8843 100644 --- a/start.py +++ b/start.py @@ -7,6 +7,8 @@ import pathlib import platform import subprocess import sys +from shutil import copyfile + from common.args import convert_args_to_dict, init_argparser @@ -129,6 +131,20 @@ if __name__ == "__main__": add_start_args(parser) args = parser.parse_args() + # Create a config if it doesn't exist + # This is not necessary to run TabbyAPI, but is new user proof + config_path = ( + pathlib.Path(args.config) if args.config else pathlib.Path("config.yml") + ) + if not config_path.exists(): + sample_config_path = pathlib.Path("config_sample.yml") + copyfile(sample_config_path, config_path) + + print( + "A config.yml wasn't found.\n" + f"Created one at {str(config_path.resolve())}" + ) + if args.ignore_upgrade: print("Ignoring pip dependency upgrade due to user request.") else: