From bf5504e14d672f9131f401292ecd528581e392a4 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron <886074+teto@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:45:11 +0200 Subject: [PATCH] improve --help output, notably '--version' possibilities --- nix_update/__init__.py | 7 ++++--- nix_update/version/version.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/nix_update/__init__.py b/nix_update/__init__.py index 0e85689..7d467c4 100644 --- a/nix_update/__init__.py +++ b/nix_update/__init__.py @@ -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() diff --git a/nix_update/version/version.py b/nix_update/version/version.py index 74eff09..c10b01f 100644 --- a/nix_update/version/version.py +++ b/nix_update/version/version.py @@ -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()