mud_server.admin_tui.config =========================== .. py:module:: mud_server.admin_tui.config .. autoapi-nested-parse:: Configuration management for PipeWorks Admin TUI. This module handles configuration from multiple sources with the following precedence (highest to lowest): 1. Command-line arguments (--server, --timeout) 2. Environment variables (MUD_SERVER_URL, MUD_REQUEST_TIMEOUT) 3. Default values The configuration is immutable once created, ensuring consistent behavior throughout the application lifecycle. .. admonition:: Example # Create config from CLI args config = Config.from_args(["--server", "http://localhost:8000"]) # Access configuration print(config.server_url) # "http://localhost:8000" print(config.timeout) # 30.0 (default) Attributes ---------- .. autoapisummary:: mud_server.admin_tui.config.DEFAULT_SERVER_URL mud_server.admin_tui.config.DEFAULT_TIMEOUT mud_server.admin_tui.config.ENV_SERVER_URL mud_server.admin_tui.config.ENV_TIMEOUT Classes ------- .. autoapisummary:: mud_server.admin_tui.config.Config Module Contents --------------- .. py:data:: DEFAULT_SERVER_URL :value: 'http://localhost:8000' .. py:data:: DEFAULT_TIMEOUT :value: 30.0 .. py:data:: ENV_SERVER_URL :value: 'MUD_SERVER_URL' .. py:data:: ENV_TIMEOUT :value: 'MUD_REQUEST_TIMEOUT' .. py:class:: Config Immutable configuration container for the Admin TUI. This dataclass holds all configuration values needed by the application. It is frozen (immutable) to prevent accidental modification after creation. .. attribute:: server_url Base URL of the MUD server API (e.g., "http://localhost:8000"). Should NOT include a trailing slash. .. attribute:: timeout HTTP request timeout in seconds. Applied to all API calls. .. admonition:: Example config = Config(server_url="http://localhost:8000", timeout=30.0) .. py:attribute:: server_url :type: str .. py:attribute:: timeout :type: float .. py:method:: from_args(args = None) :classmethod: Create a Config instance from command-line arguments. This method parses command-line arguments and falls back to environment variables and then default values for any unspecified options. :param args: Command-line arguments to parse. If None, uses sys.argv[1:]. :returns: A fully populated configuration object. :rtype: Config .. admonition:: Example # From explicit args config = Config.from_args(["--server", "http://example.com:8000"]) # From sys.argv (typical usage in main()) config = Config.from_args()