Skip to content

Commit

Permalink
Start: Create config.yml if it doesn't exist
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bdashore3 committed May 27, 2024
1 parent 116cf56 commit 4087586
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import platform
import subprocess
import sys
from shutil import copyfile

from common.args import convert_args_to_dict, init_argparser


Expand Down Expand Up @@ -129,6 +131,20 @@ def add_start_args(parser: argparse.ArgumentParser):
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:
Expand Down

0 comments on commit 4087586

Please sign in to comment.