improve --help output, notably '--version' possibilities

This commit is contained in:
Matthieu Coudron 2023-10-21 19:45:11 +02:00 committed by mergify[bot]
parent c690b76213
commit 6f21bf4db4
2 changed files with 6 additions and 5 deletions

View File

@ -65,7 +65,8 @@ def parse_args(args: list[str]) -> Options:
"--shell", action="store_true", help="provide a shell with the package"
)
parser.add_argument(
"--version", nargs="?", help="Version to update to", default="stable"
"--version", nargs="?", default=VersionPreference.STABLE,
help="Version to update to. Possible values are: " + ', '.join(VersionPreference),
)
parser.add_argument(
"--override-filename",
@ -84,7 +85,7 @@ def parse_args(args: list[str]) -> Options:
"attribute",
default=default_attribute,
nargs="?" if default_attribute else None, # type: ignore
help="Attribute name within the file evaluated",
help='''Attribute name within the file evaluated (defaults to environment variable "UPDATE_NIX_ATTR_PATH")''',
)
a = parser.parse_args(args)
@ -309,7 +310,7 @@ def main(args: list[str] = sys.argv[1:]) -> None:
if options.review:
if options.flake:
print("--review is unsupporetd with --flake")
print("--review is unsupported with --flake")
else:
nixpkgs_review()

View File

@ -1,5 +1,5 @@
from dataclasses import dataclass
from enum import Enum, auto
from enum import StrEnum, auto
@dataclass
@ -9,7 +9,7 @@ class Version:
rev: str | None = None
class VersionPreference(Enum):
class VersionPreference(StrEnum):
STABLE = auto()
UNSTABLE = auto()
FIXED = auto()