This commit is contained in:
2025-03-03 14:26:13 +03:00
parent d9c74310c3
commit 459c16ec87
13 changed files with 157 additions and 72 deletions
+4 -5
View File
@@ -130,14 +130,13 @@ class App:
def set_description_message_pattern(self, pattern: str) -> None:
first_check = re.match(r'.*{commmand}.*', pattern)
first_check = re.match(r'.*{command}.*', pattern)
second_check = re.match(r'.*{description}.*', pattern)
print(first_check)
print(second_check)
if bool(first_check) and bool(second_check):
raise InvalidDescriptionMessagePatternException(pattern)
else:
self._description_message_pattern: str = pattern
else:
raise InvalidDescriptionMessagePatternException(pattern)
def set_invalid_input_flags_handler(self, handler: Callable[[str], None]) -> None:
+3 -7
View File
@@ -15,10 +15,10 @@ T = TypeVar('T')
class Command(Generic[T]):
def __init__(self, command: str,
description: str | None = None,
description: str = None,
flags: Flag | FlagsGroup | None = None):
self._command = command
self._description = description
self._description = f'description for "{self._command}" command' if not description else description
self._registered_flags: FlagsGroup | None = flags if isinstance(flags, FlagsGroup) else FlagsGroup([flags]) if isinstance(flags, Flag) else flags
self._input_flags: FlagsGroup | None = None
@@ -29,11 +29,7 @@ class Command(Generic[T]):
def get_description(self):
if not self._description:
description = f'description for "{self._command}" command'
return description
else:
return self._description
return self._description
def get_registered_flags(self):
+1 -2
View File
@@ -48,5 +48,4 @@ class Flag:
return True
else:
return False
else:
return True
return True