mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
add Enum PossibleValues for bool values as values of possible_values argument in Flag
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
from enum import Enum
|
||||
from typing import Literal, Pattern
|
||||
|
||||
|
||||
|
||||
class PossibleValues(Enum):
|
||||
DISABLE: Literal[False] = False
|
||||
ALL: Literal[True] = True
|
||||
|
||||
def __eq__(self, other: bool) -> bool:
|
||||
return self.value == other
|
||||
|
||||
|
||||
class BaseFlag:
|
||||
def __init__(self, name: str, prefix: Literal["-", "--", "---"] = "--") -> None:
|
||||
"""
|
||||
@@ -43,7 +53,7 @@ class Flag(BaseFlag):
|
||||
self,
|
||||
name: str,
|
||||
prefix: Literal["-", "--", "---"] = "--",
|
||||
possible_values: list[str] | Pattern[str] | bool = True,
|
||||
possible_values: list[str] | Pattern[str] | PossibleValues = PossibleValues.ALL,
|
||||
) -> None:
|
||||
"""
|
||||
Public. The entity of the flag being registered for subsequent processing
|
||||
@@ -61,7 +71,7 @@ class Flag(BaseFlag):
|
||||
:param input_flag_value: The input flag value to validate
|
||||
:return: whether the entered flag is valid as bool
|
||||
"""
|
||||
if self.possible_values is False:
|
||||
if self.possible_values == PossibleValues.DISABLE:
|
||||
if input_flag_value is None:
|
||||
return True
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user