config/cli: init PKGBUILDs after main config is complete

This commit is contained in:
InsanePrawn 2023-07-09 07:16:06 +02:00
parent 6a7bfbb49b
commit 68bf43d53a

View file

@ -1,5 +1,6 @@
import click
import logging
import os
from copy import deepcopy
from typing import Any, Callable, Iterable, Mapping, Optional, Union
@ -260,6 +261,7 @@ def cmd_config_init(
):
"""Initialize the config file"""
if not non_interactive:
from packages.cli import cmd_init as cmd_init_pkgbuilds
logging.info(CONFIG_MSG)
results: dict[str, dict] = {}
for section in sections:
@ -282,6 +284,13 @@ def cmd_config_init(
config.write()
else:
return
if not non_interactive and not os.path.exists(os.path.join(config.get_path('pkgbuilds'), '.git')):
extra_msg = " This way, we can give you a list of devices and flavours later" if 'profiles' in sections else ''
if click.confirm(
f"It seems you don't have our PKGBUILDs checked out yet.\nWould you like KBS to fetch them?{extra_msg}",
default=True,
):
execute_without_exit(click.Context(cmd_config).invoke, ['packages', 'init'], cmd_init_pkgbuilds)
if 'profiles' in sections:
print("Configuring profiles")
current_profile = 'default' if 'current' not in config.file.profiles else config.file.profiles.current