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 <bdashore3@proton.me>
This commit is contained in:
parent
116cf56c87
commit
4087586449
1 changed files with 16 additions and 0 deletions
16
start.py
16
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue