Skip to content

Commit 4087586

Browse files
committed
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 <[email protected]>
1 parent 116cf56 commit 4087586

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

start.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import platform
88
import subprocess
99
import sys
10+
from shutil import copyfile
11+
1012
from common.args import convert_args_to_dict, init_argparser
1113

1214

@@ -129,6 +131,20 @@ def add_start_args(parser: argparse.ArgumentParser):
129131
add_start_args(parser)
130132
args = parser.parse_args()
131133

134+
# Create a config if it doesn't exist
135+
# This is not necessary to run TabbyAPI, but is new user proof
136+
config_path = (
137+
pathlib.Path(args.config) if args.config else pathlib.Path("config.yml")
138+
)
139+
if not config_path.exists():
140+
sample_config_path = pathlib.Path("config_sample.yml")
141+
copyfile(sample_config_path, config_path)
142+
143+
print(
144+
"A config.yml wasn't found.\n"
145+
f"Created one at {str(config_path.resolve())}"
146+
)
147+
132148
if args.ignore_upgrade:
133149
print("Ignoring pip dependency upgrade due to user request.")
134150
else:

0 commit comments

Comments
 (0)