work, fix etc.

This commit is contained in:
2025-04-26 22:23:35 +03:00
parent 9b2fc87e33
commit 61e4502e41
6 changed files with 84 additions and 118 deletions
-97
View File
@@ -334,22 +334,6 @@ Public. Sets the handler for exit command when entering a command
--- ---
<a id="argenta.app.models.App.run_polling"></a>
#### run\_polling
```python
def run_polling() -> None
```
Private. Starts the user input processing cycle
**Returns**:
`None`
---
<a id="argenta.app.models.App.include_router"></a> <a id="argenta.app.models.App.include_router"></a>
#### include\_router #### include\_router
@@ -494,26 +478,6 @@ Public. The static dividing line
--- ---
<a id="argenta.app.dividing_line.models.StaticDividingLine.get_full_static_line"></a>
#### get\_full\_static\_line
```python
def get_full_static_line(is_override: bool) -> str
```
Private. Returns the full line of the dividing line
**Arguments**:
- `is_override`: has the default text layout been redefined
**Returns**:
full line of dividing line as str
---
<a id="argenta.app.dividing_line.models.DynamicDividingLine"></a> <a id="argenta.app.dividing_line.models.DynamicDividingLine"></a>
## DynamicDividingLine Objects ## DynamicDividingLine Objects
@@ -542,27 +506,6 @@ Public. The dynamic dividing line
--- ---
<a id="argenta.app.dividing_line.models.DynamicDividingLine.get_full_dynamic_line"></a>
#### get\_full\_dynamic\_line
```python
def get_full_dynamic_line(length: int, is_override: bool) -> str
```
Private. Returns the full line of the dividing line
**Arguments**:
- `length`: the length of the dividing line
- `is_override`: has the default text layout been redefined
**Returns**:
full line of dividing line as str
---
<a id="argenta.app.exceptions"></a> <a id="argenta.app.exceptions"></a>
# `.app.exceptions` # `.app.exceptions`
@@ -1233,46 +1176,6 @@ Public. Registers handler for invalid input flag
--- ---
<a id="argenta.router.entity.Router.input_command_handler"></a>
#### input\_command\_handler
```python
def input_command_handler(input_command: InputCommand) -> None
```
Private. One handler for all input commands
**Arguments**:
- `input_command`: input command as InputCommand
**Returns**:
`None`
---
<a id="argenta.router.entity.Router.set_command_register_ignore"></a>
#### set\_command\_register\_ignore
```python
def set_command_register_ignore(_: bool) -> None
```
Private. Sets the router behavior on the input commands register
**Arguments**:
- `_`: is command register ignore
**Returns**:
`None`
---
<a id="argenta.router.entity.Router.get_triggers"></a> <a id="argenta.router.entity.Router.get_triggers"></a>
#### get\_triggers #### get\_triggers
+5 -12
View File
@@ -1,13 +1,6 @@
from argenta.command.flag.defaults import PredefinedFlags from argenta.app import App
from argenta.command.models import InputCommand
router = Router() app = App()
flag = PredefinedFlags.SHORT_HELP app._all_registered_triggers_in_lower = ['fr', 'Tre', 'Pre']
print(app._is_unknown_command(InputCommand('fr')))
@router.command(Command('test', flags=flag))
def test(args: InputFlags):
print(f'help for {args.get_flag('h').get_name()} flag')
app = App(override_system_messages=True,
print_func=print)
app.include_router(router)
app.run_polling()
+1 -1
View File
@@ -1,4 +1,4 @@
__all__ = ["Router"] __all__ = ["Router"]
from src.argenta.router.entity import Router from argenta.router.entity import Router
+5 -5
View File
@@ -1,10 +1,10 @@
from typing import Callable from typing import Callable
from inspect import getfullargspec from inspect import getfullargspec
from src.argenta.command import Command from argenta.command import Command
from src.argenta.command.models import InputCommand from argenta.command.models import InputCommand
from src.argenta.router.command_handler.entity import CommandHandlers, CommandHandler from argenta.router.command_handler.entity import CommandHandlers, CommandHandler
from src.argenta.command.flag.models import Flag, Flags, InputFlags from argenta.command.flag.models import Flag, Flags, InputFlags
from src.argenta.router.exceptions import (RepeatedFlagNameException, from argenta.router.exceptions import (RepeatedFlagNameException,
TooManyTransferredArgsException, TooManyTransferredArgsException,
RequiredArgumentNotPassedException, RequiredArgumentNotPassedException,
TriggerContainSpacesException) TriggerContainSpacesException)
+54
View File
@@ -0,0 +1,54 @@
from argenta.command.models import InputCommand, Command
from src.argenta.app import App
import unittest
class MyTestCase(unittest.TestCase):
def test_is_exit_command1(self):
app = App()
self.assertEqual(app._is_exit_command(InputCommand('q')), True)
def test_is_exit_command5(self):
app = App()
self.assertEqual(app._is_exit_command(InputCommand('Q')), True)
def test_is_exit_command2(self):
app = App(ignore_command_register=False)
self.assertEqual(app._is_exit_command(InputCommand('q')), False)
def test_is_exit_command3(self):
app = App(exit_command=Command('quit'))
self.assertEqual(app._is_exit_command(InputCommand('quit')), True)
def test_is_exit_command4(self):
app = App(exit_command=Command('quit'))
self.assertEqual(app._is_exit_command(InputCommand('qUIt')), True)
def test_is_exit_command6(self):
app = App(ignore_command_register=False,
exit_command=Command('quit'))
self.assertEqual(app._is_exit_command(InputCommand('qUIt')), False)
def test_is_unknown_command1(self):
app = App()
app._all_registered_triggers_in_lower = ['fr', 'tr', 'de']
self.assertEqual(app._is_unknown_command(InputCommand('fr')), False)
+16
View File
@@ -31,3 +31,19 @@ class TestInputCommand(unittest.TestCase):
command = Command('some', flags=Flags(Flag('test'), Flag('more'))) command = Command('some', flags=Flags(Flag('test'), Flag('more')))
self.assertEqual(command.validate_input_flag(InputFlag('more')), True) self.assertEqual(command.validate_input_flag(InputFlag('more')), True)
def test_validate_incorrect_input_flag1(self):
command = Command('some', flags=Flags(Flag('test')))
self.assertEqual(command.validate_input_flag(InputFlag('more')), False)
def test_validate_incorrect_input_flag2(self):
command = Command('some', flags=Flags(Flag('test'), Flag('more')))
self.assertEqual(command.validate_input_flag(InputFlag('case')), False)
def test_validate_incorrect_input_flag3(self):
command = Command('some')
self.assertEqual(command.validate_input_flag(InputFlag('case')), False)
def test_isinstance_parse_correct_raw_command(self):
cmd = InputCommand.parse('ssh --host 192.168.0.3')
self.assertIsInstance(cmd, InputCommand)