|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +from enum import Enum |
3 | 4 | from pathlib import Path |
4 | 5 | from typing import TYPE_CHECKING, assert_never |
5 | 6 |
|
|
24 | 25 | _: Callable[[str], DeferredTranslation] |
25 | 26 |
|
26 | 27 |
|
| 28 | +class PostInstallationAction(Enum): |
| 29 | + EXIT = str(_('Exit archinstall')) |
| 30 | + REBOOT = str(_('Reboot system')) |
| 31 | + CHROOT = str(_('chroot into installation for post-installation configurations')) |
| 32 | + |
| 33 | + |
27 | 34 | def ask_ntp(preset: bool = True) -> bool: |
28 | 35 | header = str(_('Would you like to use automatic time synchronization (NTP) with the default time servers?\n')) + '\n' |
29 | 36 | header += str(_( |
@@ -281,19 +288,25 @@ def validator(s: str) -> str | None: |
281 | 288 | return downloads |
282 | 289 |
|
283 | 290 |
|
284 | | -def ask_chroot() -> bool: |
285 | | - prompt = str(_('Would you like to chroot into the newly created installation and perform post-installation configuration?')) + '\n' |
286 | | - group = MenuItemGroup.yes_no() |
| 291 | +def ask_post_installation() -> PostInstallationAction: |
| 292 | + header = str(_('Installation completed')) + '\n\n' |
| 293 | + header += str(_('What would you like to do next?')) + '\n' |
| 294 | + |
| 295 | + items = [MenuItem(action.value, value=action) for action in PostInstallationAction] |
| 296 | + group = MenuItemGroup(items) |
287 | 297 |
|
288 | 298 | result = SelectMenu( |
289 | 299 | group, |
290 | | - header=prompt, |
| 300 | + header=header, |
| 301 | + allow_skip=False, |
291 | 302 | alignment=Alignment.CENTER, |
292 | | - columns=2, |
293 | | - orientation=Orientation.HORIZONTAL, |
294 | 303 | ).run() |
295 | 304 |
|
296 | | - return result.item() == MenuItem.yes() |
| 305 | + match result.type_: |
| 306 | + case ResultType.Selection: |
| 307 | + return result.get_value() |
| 308 | + case _: |
| 309 | + raise ValueError('Post installation action not handled') |
297 | 310 |
|
298 | 311 |
|
299 | 312 | def ask_abort() -> None: |
|
0 commit comments