clan-flash: --keymap option also sets xserver keymap now. renamed 'clan flash apply' to clan 'flash write'

This commit is contained in:
Qubasa
2024-10-11 20:51:59 +02:00
parent debeabf85e
commit 95cb7d66a7
8 changed files with 22 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
# !/usr/bin/env python3
import argparse
from .flash_cmd import register_flash_apply_parser
from .flash_cmd import register_flash_write_parser
from .list import register_flash_list_parser
@@ -14,11 +14,13 @@ def register_parser(parser: argparse.ArgumentParser) -> None:
required=True,
)
apply_parser = subparser.add_parser(
"apply",
help="Flash a machine",
write_parser = subparser.add_parser(
"write",
help="Flash a machine to a disk",
)
register_flash_apply_parser(apply_parser)
register_flash_write_parser(write_parser)
list_parser = subparser.add_parser("list", help="List options")
list_parser = subparser.add_parser(
"list", help="List possible keymaps or languages"
)
register_flash_list_parser(list_parser)

View File

@@ -73,7 +73,7 @@ def flash_machine(
if system_config.language not in list_possible_languages():
msg = (
f"Language '{system_config.language}' is not a valid language. "
f"Run 'clan flash --list-languages' to see a list of possible languages."
f"Run 'clan flash list languages' to see a list of possible languages."
)
raise ClanError(msg)
system_config_nix["i18n"] = {"defaultLocale": system_config.language}
@@ -82,10 +82,13 @@ def flash_machine(
if system_config.keymap not in list_possible_keymaps():
msg = (
f"Keymap '{system_config.keymap}' is not a valid keymap. "
f"Run 'clan flash --list-keymaps' to see a list of possible keymaps."
f"Run 'clan flash list keymaps' to see a list of possible keymaps."
)
raise ClanError(msg)
system_config_nix["console"] = {"keyMap": system_config.keymap}
system_config_nix["services"] = {
"xserver": {"xkb": {"layout": system_config.keymap}}
}
if system_config.ssh_keys_path:
root_keys = []

View File

@@ -101,7 +101,7 @@ def flash_command(args: argparse.Namespace) -> None:
)
def register_flash_apply_parser(parser: argparse.ArgumentParser) -> None:
def register_flash_write_parser(parser: argparse.ArgumentParser) -> None:
machines_parser = parser.add_argument(
"machine",
type=str,

View File

@@ -60,11 +60,11 @@ def list_possible_keymaps() -> list[str]:
def list_command(args: argparse.Namespace) -> None:
if args.options == "languages":
if args.cmd == "languages":
languages = list_possible_languages()
for language in languages:
print(language)
elif args.options == "keymaps":
elif args.cmd == "keymaps":
keymaps = list_possible_keymaps()
for keymap in keymaps:
print(keymap)
@@ -72,7 +72,7 @@ def list_command(args: argparse.Namespace) -> None:
def register_flash_list_parser(parser: argparse.ArgumentParser) -> None:
parser.add_argument(
"OPTION",
"cmd",
choices=["languages", "keymaps"],
type=str,
help="list possible languages or keymaps",