docs: add CLI documentation section with translations and code snippets; refactor mock/ to examples/, improve CLI module (bug fixes, DX, error handling)

This commit is contained in:
2026-07-25 19:22:04 +03:00
parent 311b312ab4
commit 6b9bea155f
21 changed files with 824 additions and 219 deletions
View File
View File
+26
View File
@@ -0,0 +1,26 @@
from prompt_toolkit import HTML
from argenta import App, Orchestrator
from argenta.app import PredefinedMessages, StaticDividingLine, AutoCompleter
from argenta.app.dividing_line.models import DynamicDividingLine
from argenta.orchestrator import ArgParser
from examples.example_app.routers import work_router
app: App = App(
dividing_line=StaticDividingLine('~')
)
orchestrator: Orchestrator = Orchestrator()
def main():
app.include_router(work_router)
app.add_message_on_startup(PredefinedMessages.USAGE)
app.add_message_on_startup(PredefinedMessages.AUTOCOMPLETE)
app.add_message_on_startup(PredefinedMessages.HELP)
orchestrator.run_repl(app)
if __name__ == "__main__":
main()
+18
View File
@@ -0,0 +1,18 @@
from argenta import Command, Response, Router
from argenta.command import Flag, Flags
from argenta.command.flag import ValidationStatus
work_router: Router = Router(title="Base points:")
@work_router.command(
Command(
"hello",
flags=Flags([
Flag("test")
]),
description="Hello, world!")
)
def command_help(response: Response):
n = input('sfgdheth')
print(f"Hello,{n} {response.input_flags.get_flag_by_name('test', with_status=ValidationStatus.VALID)}")
+16
View File
@@ -0,0 +1,16 @@
# main.py
from argenta import App, Orchestrator
from argenta.app import DynamicDividingLine
from .routers import router
app: App = App(prompt='>>> ', dividing_line=None)
orchestrator: Orchestrator = Orchestrator()
def main() -> None:
app.include_router(router)
orchestrator.run_repl(app)
if __name__ == '__main__':
main()
+9
View File
@@ -0,0 +1,9 @@
# routers.py
from argenta import Command, Response, Router
router = Router(title="Quickstart Example")
@router.command(Command("hello", description="Say hello"))
def handler(response: Response):
print("Hello, world!")