cligram.app
Main application module.
- class cligram.app.Application(config)[source]
Bases:
objectMain application class for cligram.
Manages configuration, state, signal handling, and application lifecycle.
- add_shutdown_callback(callback)[source]
Register a callback to be called on application shutdown.
- Parameters:
callback (
Callable[[Application],None]) – A callable that takes the application instance as an argument.- Return type:
- check_shutdown()[source]
Check if shutdown has been requested.
- Raises:
asyncio.CancelledError – If shutdown event is set
- config
Application configuration.
- console
Rich console for formatted output.
-
device:
DeviceInfo Information about the current device.
-
shutdown_event:
Event Event to signal application shutdown.
- async sleep()[source]
Sleep for a configured delay while checking for shutdown.
Note: this method is not precise and it is an intended behavior
- Raises:
asyncio.CancelledError – If shutdown is requested during sleep
- start(task)[source]
Initialize application and run the main task in the event loop.
Initializes signal handlers, loads state, and executes the provided task. After task completion, saves state and performs cleanup. Raised exceptions are logged and re-raised.
- Parameters:
task (
Union[Callable[[Application],Coroutine],Coroutine]) – Either an async function that accepts Application, or a coroutine- Raises:
ApplicationAlreadyRunningError – If an application is already running
TypeError – If the provided task is not awaitable
- Return type:
- state
“State manager for application state persistence.
-
status:
Status Rich status indicator for CLI feedback.