mud_server.admin_tui.config

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.

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

DEFAULT_SERVER_URL

DEFAULT_TIMEOUT

ENV_SERVER_URL

ENV_TIMEOUT

Classes

Config

Immutable configuration container for the Admin TUI.

Module Contents

mud_server.admin_tui.config.DEFAULT_SERVER_URL = 'http://localhost:8000'
mud_server.admin_tui.config.DEFAULT_TIMEOUT = 30.0
mud_server.admin_tui.config.ENV_SERVER_URL = 'MUD_SERVER_URL'
mud_server.admin_tui.config.ENV_TIMEOUT = 'MUD_REQUEST_TIMEOUT'
class mud_server.admin_tui.config.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.

server_url

Base URL of the MUD server API (e.g., “http://localhost:8000”). Should NOT include a trailing slash.

timeout

HTTP request timeout in seconds. Applied to all API calls.

Example

config = Config(server_url=”http://localhost:8000”, timeout=30.0)

server_url: str
timeout: float
classmethod from_args(args=None)

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.

Parameters:

args (collections.abc.Sequence[str] | None) – Command-line arguments to parse. If None, uses sys.argv[1:].

Returns:

A fully populated configuration object.

Return type:

Config

Example

# From explicit args config = Config.from_args([”–server”, “http://example.com:8000”])

# From sys.argv (typical usage in main()) config = Config.from_args()