Implement static config for server info

This commit is contained in:
Logan Cusano
2025-06-22 22:08:25 -04:00
parent 84135f1eb0
commit 01f892a6db
3 changed files with 22 additions and 7 deletions

View File

@@ -11,9 +11,6 @@ build:
# Target to run the server container using the host network # Target to run the server container using the host network
run: build run: build
docker run -it --rm \ docker run -it --rm \
-e SERVER_WS_URI=${SERVER_WS_URI} \ -v "$(pwd)/data":/data \
-e SERVER_API_URL=${SERVER_API_URL} \
-e CLIENT_API_URL=${CLIENT_API_URL} \
-v $(pwd)/data:/data \
--network=host \ --network=host \
$(CLIENT_IMAGE) $(CLIENT_IMAGE)

View File

@@ -30,6 +30,8 @@ if not app_conf.get("nickname"):
app_conf.set("nickname", generated_nickname) app_conf.set("nickname", generated_nickname)
NICKNAME = app_conf.get("nickname") NICKNAME = app_conf.get("nickname")
print(app_conf)
# ---------------------------- # ----------------------------
# Dictionary mapping command names (strings) to local client functions # Dictionary mapping command names (strings) to local client functions

View File

@@ -89,6 +89,22 @@ class Config:
else: else:
print(f"Warning: Key '{key}' not found in config.") print(f"Warning: Key '{key}' not found in config.")
def __str__(self):
"""
Returns a neat, formatted string representation of all configuration
key-value pairs. This method is automatically called when the object
is converted to a string (e.g., by print()).
"""
if not self._config_data:
return "\n--- Configuration is Empty ---\n"
output = ["\n--- Current Configuration ---"]
max_key_len = max(len(key) for key in self._config_data)
for key, value in self._config_data.items():
output.append(f"{key.ljust(max_key_len)} : {json.dumps(value, indent=None)}")
output.append("-----------------------------\n")
return "\n".join(output)
def __getattr__(self, name): def __getattr__(self, name):
""" """
Allows accessing configuration values using attribute notation (e.g., config.my_key). Allows accessing configuration values using attribute notation (e.g., config.my_key).