Expand description
Configuration and authentication management. Configuration and authentication for the ROMM client.
This module is deliberately independent of any particular frontend:
both the TUI and the command-line subcommands share the same Config
and AuthConfig types.
§Configuration precedence
Configuration is layered per field. Lowest precedence wins first; higher layers override
only the fields they set. There is no automatic .env file loading.
§Layer 1 — built-in defaults
Examples: use_https = true, theme terminal, OS download directory when unset.
§Layer 2 — config.json
User file at [user_config_json_path], written by romm-cli init, the TUI setup wizard,
Settings, or auth login. Fills fields not set by higher layers.
§Layer 3 — process environment
Overrides config.json per field in [load_config]. Includes API_BASE_URL,
ROMM_ROMS_DIR / ROMM_DOWNLOAD_DIR, API_USE_HTTPS, auth vars (API_TOKEN,
ROMM_TOKEN_FILE / API_TOKEN_FILE, etc.), ROMM_THEME, and path overrides
(ROMM_CACHE_PATH, ROMM_OPENAPI_PATH, …).
§Layer 4 — OS keyring
After env + JSON merge, secrets that are still placeholders (including
[KEYRING_SECRET_PLACEHOLDER]) are resolved via the OS keyring (keyring crate, service
romm-cli). On Windows the stored credential target is typically
API_TOKEN.romm-cli, API_PASSWORD.romm-cli, or API_KEY.romm-cli. Missing entries are
silent; other keyring errors are logged at warn (never with secret values). On save, a
successful store is followed by read-back verification before writing the sentinel to JSON.
§Layer 5 — command-specific CLI (runtime only)
Narrow exceptions on top of [load_config] for a single invocation (not global):
| Command / flag | Effect |
|---|---|
download -o / --output | Download directory for that run; ignores env and file |
sync run --download-dir | Save download base; defaults to manifest parent, not save_sync.save_dir |
init / auth login flags | Persist to config.json; effective on the next run unless env overrides |
There are no global --url / --token flags on normal API commands; connection settings
come from env + file + keyring via [load_config].
Structs§
- Config
- High-level configuration for the
romm-cliapplication. - Extras
Defaults - Default checked state for categories in the TUI extras picker (when each row exists).
- Roms
Layout Config - Per-console ROM storage layout preferences.
- Save
Sync Config - Save sync preferences shared by CLI/TUI frontends.
- TuiLayout
Config - TUI panel layout preferences (library split and game detail cover width).
Enums§
- Auth
Config - Supported authentication modes for the RomM API.
Constants§
- DEFAULT_
THEME_ ID - Default TUI theme ID when none is configured.
- GAME_
DETAIL_ COVER_ PANEL_ WIDTH_ DEFAULT - Default game detail cover column width in terminal cells.
- GAME_
DETAIL_ COVER_ PANEL_ WIDTH_ MAX - Maximum game detail cover column width.
- GAME_
DETAIL_ COVER_ PANEL_ WIDTH_ MIN - Minimum game detail cover column width.
- KEYRING_
SECRET_ PLACEHOLDER - Written to
config.jsonwhen the real secret is stored in the OS keyring (persist_user_config). - LIBRARY_
LEFT_ PANEL_ PERCENT_ DEFAULT - Default library browse split: left pane width as a percentage.
- LIBRARY_
LEFT_ PANEL_ PERCENT_ MAX - Maximum library left pane width (percent).
- LIBRARY_
LEFT_ PANEL_ PERCENT_ MIN - Minimum library left pane width (percent).
Functions§
- auth_
for_ persist_ merge - Auth to pass to
persist_user_configwhen saving non-auth fields (e.g. TUI Settings). - default_
theme_ id - disk_
has_ unresolved_ keyring_ sentinel - Returns true when
load_confighas no resolvedAuthConfig::Bearer(etc.) butconfig.jsonon disk still containsKEYRING_SECRET_PLACEHOLDER(OS keyring could not supply the secret). - is_
keyring_ placeholder - Returns true if
sis the sentinel written to disk when the secret lives in the keyring. - keyring_
get - Retrieve a secret from the OS keyring, returning
Noneif not found or on error. - keyring_
store - Store a secret in the OS keyring under the
romm-cliservice name. - load_
config - Loads the merged configuration from the process environment,
config.json, and the OS keyring. - normalize_
romm_ origin - Normalizes a RomM site URL by trimming whitespace, trailing slashes, and removing the
/apisuffix. - openapi_
cache_ path - Where the OpenAPI spec is cached (
.../romm-cli/openapi.json). - persist_
user_ config - Persists the user configuration to
config.jsonand stores secrets in the OS keyring. - read_
user_ config_ json_ from_ disk - Reads
config.jsonfrom disk only (no env merge, no keyring resolution). Used by the TUI setup wizard to detect<stored-in-keyring>placeholders. - reset_
all_ settings - Deletes the config.json file and clears the secrets from the OS keyring.
- resolve_
console_ save_ dir - Resolve the directory where save files for a console should be stored.
- resolve_
game_ save_ dir - Resolve the directory where a specific game’s saves should be downloaded.
- resolved_
save_ dir - should_
check_ updates - Returns true if the application should check for updates on startup.
- user_
config_ dir - Directory for user-level config (
romm-cliunder the OS config dir). - user_
config_ json_ path - Path to the user-level
config.jsonfile (.../romm-cli/config.json).