Files
Argenta/docs/code_snippets/quickstart/simple_app.py
T
kolo ce7e24b924 feat: impl docs (#4)
The entire public api is covered with documentation in two languages - Russian and English.

the library now supports the latest three versions of python - 3.12, 3.13 and 3.14

minor design changes: now, when a Boolean flag is entered, its value is an empty string, not None.

tests have been adapted to the supported versions of python, readmi has been redesigned in two languages, German is no longer available.
2025-12-04 21:55:19 +03:00

38 lines
959 B
Python

from argenta import App, Command, Orchestrator, Router, Response
from argenta.command import Flag
# 1. Create app and orchestrator instances
app = App(
prompt=">> ",
initial_message="Simple App",
farewell_message="Goodbye!",
repeat_command_groups_printing=False
)
orchestrator = Orchestrator()
# 2. Create router for grouping commands
main_router = Router(title="Main commands")
# 3. Define command and its handler
@main_router.command(Command(
"hello",
description="Prints greeting message",
flags=Flag("name")
))
def hello_handler(response: Response):
"""This handler will be called for 'hello' command."""
name = response.input_flags.get_flag_by_name("name")
if name:
print(f"Hello, {name.input_value}!")
else:
print("Hello, world!")
# 4. Include router to application
app.include_router(main_router)
# 5. Start application
if __name__ == "__main__":
orchestrator.start_polling(app)