refactor: skip build firmware dependency screen if all are met (#629)

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
dw-0
2025-02-09 17:04:46 +01:00
committed by GitHub
parent d8f47c0960
commit 033916216c

View File

@@ -147,16 +147,22 @@ class KlipperBuildFirmwareMenu(BaseMenu):
) )
def set_options(self) -> None: def set_options(self) -> None:
self.input_label_txt = "Press ENTER to install dependencies"
self.default_option = Option(method=self.install_missing_deps)
def run(self):
# immediately start the build process if all dependencies are met
if len(self.missing_deps) == 0: if len(self.missing_deps) == 0:
self.input_label_txt = "Press ENTER to continue" self.start_build_process()
self.default_option = Option(method=self.start_build_process)
else: else:
self.input_label_txt = "Press ENTER to install dependencies" super().run()
self.default_option = Option(method=self.install_missing_deps)
def print_menu(self) -> None: def print_menu(self) -> None:
txt = Color.apply("Dependencies are missing!", Color.RED)
menu = textwrap.dedent( menu = textwrap.dedent(
""" f"""
╟───────────────────────────────────────────────────────╢
{txt:^62}
╟───────────────────────────────────────────────────────╢ ╟───────────────────────────────────────────────────────╢
║ The following dependencies are required: ║ ║ The following dependencies are required: ║
║ ║ ║ ║
@@ -170,16 +176,8 @@ class KlipperBuildFirmwareMenu(BaseMenu):
padding = 40 - len(d) + len(status) + (len(status_ok) - len(status)) padding = 40 - len(d) + len(status) + (len(status_ok) - len(status))
d = Color.apply(f"{d}", Color.CYAN) d = Color.apply(f"{d}", Color.CYAN)
menu += f"{d}{status:>{padding}}\n" menu += f"{d}{status:>{padding}}\n"
menu += "║ ║\n" menu += "║ ║\n"
color = Color.GREEN if len(self.missing_deps) == 0 else Color.RED
txt = (
"All dependencies are met!"
if len(self.missing_deps) == 0
else "Dependencies are missing!"
)
menu += f"{Color.apply(txt, color):<62}\n"
menu += "╟───────────────────────────────────────────────────────╢\n" menu += "╟───────────────────────────────────────────────────────╢\n"
print(menu, end="") print(menu, end="")