work on v0.3.0

This commit is contained in:
2025-02-21 01:46:03 +03:00
parent 79ccfbb3b1
commit 905698384a
9 changed files with 52 additions and 14 deletions
+6 -2
View File
@@ -1,4 +1,4 @@
from ..input_comand.exceptions import IncorrectInputFlagException
from ..input_comand.exceptions import IncorrectInputFlagException, RepeatedInputFlagsException
from ..entity import Command
from ..params.flag.flags_group.entity import FlagsGroup
from ..params.flag.input_flag.entity import InputFlag
@@ -46,7 +46,11 @@ class InputCommand(Command, Generic[T]):
flag_prefix=flag_prefix)
input_flag.set_value(current_flag_value)
flags.add_flag(input_flag)
all_flags = [x.get_string_entity() for x in flags.get_flags()]
if input_flag.get_string_entity() not in all_flags:
flags.add_flag(input_flag)
else:
raise RepeatedInputFlagsException(input_flag)
current_flag_name = None
current_flag_value = None
@@ -13,4 +13,12 @@ class IncorrectInputFlagException(Exception):
return "Incorrect Input Flags"
class RepeatedInputFlagsException(Exception):
def __init__(self, flag: InputFlag):
self.flag = flag
def __str__(self):
return ("Repeated Input Flags\n"
f"Duplicate flag was detected in the input: '{self.flag.get_string_entity()}'")