rojo/tools/atlas-daemon/atlas_daemon/config.py
Joe 9934094dbc Enhance Roblox API integration and refactor CLI commands
- Updated the `clap` dependency in `Cargo.toml` to include the "env" feature for improved command-line argument handling.
- Introduced a new `roblox_api` module to encapsulate Roblox API interactions, including authentication and asset downloading.
- Refactored the `CloneCommand` and `StudioCommand` to utilize the new `roblox_api` functions for fetching experience names and universe IDs, enhancing code clarity and reducing duplication.
- Removed obsolete functions related to Roblox API calls from the CLI commands, streamlining the codebase.
- Added error handling for authentication failures, ensuring better user feedback when required credentials are missing.

These changes aim to improve the overall structure and functionality of the CLI while enhancing the integration with the Roblox API.
2026-03-01 20:03:40 -06:00

34 lines
1.1 KiB
Python

from __future__ import annotations
import os
from dataclasses import dataclass, field
from pathlib import Path
@dataclass
class Config:
discord_token: str
anthropic_key: str
data_dir: Path = field(default_factory=lambda: Path("./atlas-daemon-data"))
encryption_key: str = ""
sync_interval: int = 300
max_games_per_server: int = 5
atlas_binary: str = "atlas"
@classmethod
def from_env(cls, **overrides: object) -> Config:
def _get(key: str, default: str = "") -> str:
override = overrides.get(key.lower().removeprefix("atlas_daemon_"))
if override is not None:
return str(override)
return os.environ.get(f"ATLAS_DAEMON_{key}", default)
return cls(
discord_token=_get("DISCORD_TOKEN"),
anthropic_key=_get("ANTHROPIC_KEY"),
data_dir=Path(_get("DATA_DIR", "./atlas-daemon-data")),
encryption_key=_get("ENCRYPTION_KEY"),
sync_interval=int(_get("SYNC_INTERVAL", "300")),
max_games_per_server=int(_get("MAX_GAMES_PER_SERVER", "5")),
atlas_binary=_get("ATLAS_BINARY", "atlas"),
)