work on stable major version

This commit is contained in:
2025-04-30 15:48:38 +03:00
parent 1159dda16e
commit 5a17e916eb
7 changed files with 60 additions and 19 deletions
+20 -3
View File
@@ -1,6 +1,23 @@
from argenta.response import Response, Status
from argenta.app import App
from argenta.app.dividing_line import StaticDividingLine, DynamicDividingLine
from argenta.app.autocompleter import AutoCompleter
from argenta.app.defaults import PredefinedMessages
from argenta.command import Command
from argenta.command.flags import Flags, InputFlags, InvalidValueInputFlags, UndefinedInputFlags, ValidInputFlags
from argenta.command.flag import Flag, InputFlag
from argenta.command.flag.defaults import PredefinedFlags
from argenta.router import Router
from argenta.orchestrator import Orchestrator
from argenta.command.models import InputCommand
app = App()
app._all_registered_triggers_in_lower = ['fr', 'Tre', 'Pre']
print(app._is_unknown_command(InputCommand('fr')))
while True:
cmd = input(">>> ")
if cmd == "exit":
break
else:
parse_cmd: InputCommand = InputCommand.parse(cmd)
print(f'name: {parse_cmd.get_trigger()}\n'
f'flags: {parse_cmd.get_input_flags().get_flags()}\n')
-1
View File
@@ -25,7 +25,6 @@ def command_help(response: Response):
@work_router.command(Command('run', 'Run All'))
def command_start_solving(response: Response):
print(response.status)
print('srsfbd')
print(response.undefined_flags.get_flags())
print(response.valid_flags.get_flags())
print(response.invalid_value_flags.get_flags())
+3
View File
@@ -1 +1,4 @@
__all__ = ["Flag", "InputFlag"]
from argenta.command.flag.models import Flag, InputFlag
+10
View File
@@ -0,0 +1,10 @@
__all__ = ["Flags", "InputFlags",
"UndefinedInputFlags",
"InvalidValueInputFlags",
"ValidInputFlags"]
from argenta.command.flags.models import (Flags, InputFlags,
UndefinedInputFlags,
InvalidValueInputFlags,
ValidInputFlags)
+3 -3
View File
@@ -1,5 +1,5 @@
__all__ = ["Response", "Status"]
from argenta.response.entity import Response
from argenta.response.status import Status
__all__ = ['Response', 'Status']
+4 -3
View File
@@ -2,7 +2,8 @@ from enum import Enum
class Status(Enum):
SUCCESSFUL = 200
partSUCCESSFUL = 206
UNSUCCESSFUL = 400
ALL_FLAGS_VALID = 'ALL_FLAGS_VALID'
UNDEFINED_FLAGS = 'UNDEFINED_FLAGS'
INVALID_VALUE_FLAGS = 'INVALID_VALUE_FLAGS'
UNDEFINED_AND_INVALID_FLAGS = 'UNDEFINED_AND_INVALID_FLAGS'
+20 -9
View File
@@ -72,28 +72,29 @@ class Router:
response: Response = Response()
if handle_command.get_registered_flags().get_flags():
if input_command_flags.get_flags():
response.status = Status.SUCCESSFUL
flags = self._validate_input_flags(handle_command, input_command_flags)
flags, status = self._validate_input_flags(handle_command, input_command_flags)
response.valid_flags, response.undefined_flags, response.invalid_value_flags = flags
response.status = status
command_handler.handling(response)
else:
response.status = Status.SUCCESSFUL
response.status = Status.ALL_FLAGS_VALID
command_handler.handling(response)
else:
if input_command_flags.get_flags():
response.status = Status.UNSUCCESSFUL
response.status = Status.UNDEFINED_FLAGS
response.undefined_flags = UndefinedInputFlags()
response.undefined_flags.add_flags(input_command_flags.get_flags())
command_handler.handling(response)
else:
response.status = Status.SUCCESSFUL
response.status = Status.ALL_FLAGS_VALID
command_handler.handling(response)
@staticmethod
def _validate_input_flags(handled_command: Command, input_flags: InputFlags) -> tuple[ValidInputFlags,
UndefinedInputFlags,
InvalidValueInputFlags]:
def _validate_input_flags(handled_command: Command, input_flags: InputFlags) -> tuple[tuple[ValidInputFlags,
UndefinedInputFlags,
InvalidValueInputFlags],
Status]:
"""
Private. Validates flags of input command
:param handled_command: entity of the handled command
@@ -112,7 +113,17 @@ class Router:
undefined_input_flags.add_flag(flag)
case 'Invalid':
invalid_value_input_flags.add_flag(flag)
return valid_input_flags, undefined_input_flags, invalid_value_input_flags
if not invalid_value_input_flags.get_flags() and not undefined_input_flags.get_flags():
status = Status.ALL_FLAGS_VALID
elif invalid_value_input_flags.get_flags() and not undefined_input_flags.get_flags():
status = Status.INVALID_VALUE_FLAGS
elif not invalid_value_input_flags.get_flags() and undefined_input_flags.get_flags():
status = Status.UNDEFINED_FLAGS
else:
status = Status.UNDEFINED_AND_INVALID_FLAGS
return (valid_input_flags, undefined_input_flags, invalid_value_input_flags), status
@staticmethod