nixos-rebuild-ng: use -s as copy_flags
This commit is contained in:
@@ -56,7 +56,13 @@ def get_parser() -> tuple[argparse.ArgumentParser, dict[str, argparse.ArgumentPa
|
||||
|
||||
copy_flags = argparse.ArgumentParser(add_help=False)
|
||||
copy_flags.add_argument(
|
||||
"--use-substitutes", "--substitute-on-destination", "-s", action="store_true"
|
||||
"--use-substitutes",
|
||||
"--substitute-on-destination",
|
||||
"-s",
|
||||
action="store_true",
|
||||
# `-s` is the destination since it has the same meaning in
|
||||
# `nix-copy-closure` and `nix copy`
|
||||
dest="s",
|
||||
)
|
||||
|
||||
sub_parsers = {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import logging
|
||||
from typing import TypeAlias, override
|
||||
from typing import TypeAlias, assert_never, override
|
||||
|
||||
Args: TypeAlias = bool | str | list[str] | int | None
|
||||
|
||||
@@ -25,6 +25,8 @@ def dict_to_flags(d: dict[str, Args]) -> list[str]:
|
||||
match value:
|
||||
case None | False | 0 | []:
|
||||
continue
|
||||
case True if len(key) == 1:
|
||||
flags.append(f"-{key}")
|
||||
case True:
|
||||
flags.append(flag)
|
||||
case int():
|
||||
@@ -36,4 +38,6 @@ def dict_to_flags(d: dict[str, Args]) -> list[str]:
|
||||
flags.append(flag)
|
||||
for v in value:
|
||||
flags.append(v)
|
||||
case _:
|
||||
assert_never(value)
|
||||
return flags
|
||||
|
||||
@@ -9,6 +9,7 @@ def test_dict_to_flags() -> None:
|
||||
"test_flag_3": "value",
|
||||
"test_flag_4": ["v1", "v2"],
|
||||
"test_flag_5": None,
|
||||
"t": True,
|
||||
"verbose": 5,
|
||||
}
|
||||
)
|
||||
@@ -19,6 +20,7 @@ def test_dict_to_flags() -> None:
|
||||
"--test-flag-4",
|
||||
"v1",
|
||||
"v2",
|
||||
"-t",
|
||||
"-vvvvv",
|
||||
]
|
||||
r2 = u.dict_to_flags({"verbose": 0, "empty_list": []})
|
||||
|
||||
Reference in New Issue
Block a user