mud_server.admin_tui.app
Main application module for PipeWorks Admin TUI.
This module defines the AdminApp class, which is the main Textual application for the admin interface. It manages: - Screen navigation (login -> dashboard) - API client lifecycle - Authentication flow
- Entry Point:
The main() function serves as the CLI entry point, configured in pyproject.toml as the “pipeworks-admin-tui” console script.
Example
# Run from command line pipeworks-admin-tui –server http://localhost:8000
# Or programmatically from mud_server.admin_tui import AdminApp, Config
config = Config.from_args() app = AdminApp(config) app.run()
Classes
Main Textual application for PipeWorks Admin TUI. |
Functions
|
Main entry point for the Admin TUI. |
Module Contents
- class mud_server.admin_tui.app.AdminApp(config)
Bases:
textual.app.AppMain Textual application for PipeWorks Admin TUI.
This application provides a terminal-based interface for administering the MUD server. It handles authentication, displays server status, and provides administrative actions.
- config
Application configuration (server URL, timeout).
- api_client
HTTP client for server communication. Created on mount.
- Lifecycle:
on_mount: Creates API client, pushes LoginScreen
do_login: Authenticates, switches to DashboardScreen
do_logout: Clears session, returns to LoginScreen
on_unmount: Closes API client
- Key Bindings (App-level):
ctrl+c: Quit application (always available) ctrl+q: Quit application (always available)
Example
config = Config(server_url=”http://localhost:8000”, timeout=30.0) app = AdminApp(config) app.run()
Initialize the admin application.
- Parameters:
config (mud_server.admin_tui.config.Config) – Application configuration object.
- TITLE = 'PipeWorks Admin'
- SUB_TITLE = 'MUD Server Administration'
- BINDINGS
- CSS = Multiline-String
Show Value
""" Screen { background: $surface; } """
- config
- keybindings
- api_client: mud_server.admin_tui.api.client.AdminAPIClient | None = None
- async on_mount()
Called when the application is mounted.
Creates the API client and pushes the initial login screen.
- async on_unmount()
Called when the application is unmounted.
Logs out from server (if authenticated) and closes the API client. This ensures the session is properly cleaned up on the server side, keeping the active player count accurate.
- async do_login(username, password)
Perform login and transition to dashboard.
Called by LoginScreen when credentials are submitted.
- Parameters:
- Raises:
AuthenticationError – If login fails.
- async do_logout()
Perform logout and return to login screen.
Called by DashboardScreen when user requests logout.
- mud_server.admin_tui.app.main(args=None)
Main entry point for the Admin TUI.
Parses command-line arguments, creates the application, and runs the event loop.
- Parameters:
args (collections.abc.Sequence[str] | None) – Command-line arguments. If None, uses sys.argv[1:].
- Returns:
Exit code (0 for success, non-zero for errors).
- Return type:
Example
# Normal usage (reads sys.argv) sys.exit(main())
# Testing main([”–server”, “http://localhost:8000”])