mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
working
This commit is contained in:
@@ -57,7 +57,7 @@ if __name__ == '__main__':
|
|||||||
---
|
---
|
||||||
|
|
||||||
### *class* :: `App`
|
### *class* :: `App`
|
||||||
Основной класс приложения Argenta.
|
Класс, определяющий поведение и состояние приложения
|
||||||
|
|
||||||
#### Конструктор
|
#### Конструктор
|
||||||
```python
|
```python
|
||||||
@@ -110,9 +110,9 @@ App(prompt: str = 'Enter a command',
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**App().**`set_initial_greeting(greeting: str) -> None`
|
**App().**`set_initial_message(message: str) -> None`
|
||||||
|
|
||||||
*param* `greeting: str` **::** устанавливаемое приветственное сообщение
|
*param* `message: str` **::** устанавливаемое приветственное сообщение
|
||||||
*example* **::** `"Hello, I'm a cli example app"`
|
*example* **::** `"Hello, I'm a cli example app"`
|
||||||
|
|
||||||
*method mean* **::** устанавливает сообщение, которое будет отображено при запуске программы
|
*method mean* **::** устанавливает сообщение, которое будет отображено при запуске программы
|
||||||
@@ -151,13 +151,17 @@ App(prompt: str = 'Enter a command',
|
|||||||
|
|
||||||
## Примечания
|
## Примечания
|
||||||
|
|
||||||
- pass
|
- Среди зарегистрированных в приложении роутеров должен быть один главный, является ли роутер главным
|
||||||
|
определяется значением аргумента `is_main` равным `True`, в методе `App().include_router()`, который по умолчанию равен
|
||||||
|
`False`, если в приложении зарегистрирован лишь один роутер, то он неявно устанавливается главным, если
|
||||||
|
зарегистрировано больше одного роутера, то требуется явное указание главного. При регистрации более одного
|
||||||
|
главного роутера вызывается исключение `OnlyOneMainRouterIsAllowedException`. При регистрации более одного
|
||||||
|
роутера и отсутствии указания главного вызывается исключение `MissingMainRouterException`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Исключения
|
### Исключения
|
||||||
Определены в файле `exceptions.py`:
|
|
||||||
|
|
||||||
- `InvalidRouterInstanceException` — Вызывается, если передан неверный объект роутера.
|
- `InvalidRouterInstanceException` — Вызывается, если передан неверный объект роутера.
|
||||||
- `InvalidDescriptionMessagePatternException` — Вызывается при неправильном формате шаблона описания команд.
|
- `InvalidDescriptionMessagePatternException` — Вызывается при неправильном формате шаблона описания команд.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from .exceptions import (InvalidRouterInstanceException,
|
|||||||
class App:
|
class App:
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
prompt: str = 'Enter a command',
|
prompt: str = 'Enter a command',
|
||||||
initial_greeting: str = '\nHello, I am Argenta\n',
|
initial_message: str = '\nHello, I am Argenta\n',
|
||||||
farewell_message: str = '\nGoodBye\n',
|
farewell_message: str = '\nGoodBye\n',
|
||||||
exit_command: str = 'Q',
|
exit_command: str = 'Q',
|
||||||
exit_command_description: str = 'Exit command',
|
exit_command_description: str = 'Exit command',
|
||||||
@@ -32,7 +32,7 @@ class App:
|
|||||||
self.exit_command_title = exit_command_title
|
self.exit_command_title = exit_command_title
|
||||||
self.ignore_exit_command_register = ignore_exit_command_register
|
self.ignore_exit_command_register = ignore_exit_command_register
|
||||||
self.farewell_message = farewell_message
|
self.farewell_message = farewell_message
|
||||||
self.initial_greeting = initial_greeting
|
self.initial_message = initial_message
|
||||||
self.line_separate = line_separate
|
self.line_separate = line_separate
|
||||||
self.command_group_description_separate = command_group_description_separate
|
self.command_group_description_separate = command_group_description_separate
|
||||||
self.ignore_command_register = ignore_command_register
|
self.ignore_command_register = ignore_command_register
|
||||||
@@ -50,7 +50,7 @@ class App:
|
|||||||
self._validate_main_router()
|
self._validate_main_router()
|
||||||
self._validate_all_router_commands()
|
self._validate_all_router_commands()
|
||||||
|
|
||||||
self.print_func(self.initial_greeting)
|
self.print_func(self.initial_message)
|
||||||
|
|
||||||
if not self.repeat_command_groups:
|
if not self.repeat_command_groups:
|
||||||
self._print_command_group_description()
|
self._print_command_group_description()
|
||||||
@@ -81,8 +81,8 @@ class App:
|
|||||||
self.print_func(self.prompt)
|
self.print_func(self.prompt)
|
||||||
|
|
||||||
|
|
||||||
def set_initial_greeting(self, greeting: str) -> None:
|
def set_initial_message(self, message: str) -> None:
|
||||||
self.initial_greeting: str = greeting
|
self.initial_message: str = message
|
||||||
|
|
||||||
|
|
||||||
def set_farewell_message(self, message: str) -> None:
|
def set_farewell_message(self, message: str) -> None:
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ def main():
|
|||||||
app.include_router(work_router, is_main=True)
|
app.include_router(work_router, is_main=True)
|
||||||
app.include_router(settings_router)
|
app.include_router(settings_router)
|
||||||
|
|
||||||
app.set_initial_greeting(initial_greeting)
|
app.set_initial_message(initial_greeting)
|
||||||
app.set_farewell_message(goodbye_message)
|
app.set_farewell_message(goodbye_message)
|
||||||
|
|
||||||
app.set_description_message_pattern('[bold red][{command}][/bold red] [blue]*=*=*[/blue] [bold yellow italic]{description}')
|
app.set_description_message_pattern('[bold red][{command}][/bold red] [blue]*=*=*[/blue] [bold yellow italic]{description}')
|
||||||
|
|||||||
Reference in New Issue
Block a user