Skip to main content

Module config

Module config 

Source
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

Call [load_config] to read config:

  1. Variables already set in the process environment (highest priority), including API_TOKEN and paths ROMM_TOKEN_FILE / API_TOKEN_FILE (file contents used as bearer token when API_TOKEN is unset).
  2. User config.json (see [user_config_json_path]) — fills any field not already set from the environment.

There is no automatic loading of a .env file; set variables in your shell or process manager, or rely on config.json written by romm-cli init / the TUI setup wizard.

After env + JSON merge, secrets that are still placeholders (including [KEYRING_SECRET_PLACEHOLDER]) are resolved via the OS keyring (keyring crate, service name 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.

§load_config vs config.json

[load_config] merges sources per field: process environment wins over values from config.json for API_BASE_URL, ROMM_ROMS_DIR/ROMM_DOWNLOAD_DIR, API_USE_HTTPS, and auth-related fields. The keyring is used only to replace placeholder or sentinel secret strings after that merge.

Structs§

Config
High-level configuration for the romm-cli application.
ExtrasDefaults
Default checked state for categories in the TUI extras picker (when each row exists).
RomsLayoutConfig
Per-console ROM storage layout preferences.
SaveSyncConfig
Save sync preferences shared by CLI/TUI frontends.

Enums§

AuthConfig
Supported authentication modes for the RomM API.

Constants§

DEFAULT_THEME_ID
Default TUI theme ID when none is configured.
KEYRING_SECRET_PLACEHOLDER
Written to config.json when the real secret is stored in the OS keyring (persist_user_config).

Functions§

auth_for_persist_merge
Auth to pass to persist_user_config when saving non-auth fields (e.g. TUI Settings).
default_theme_id
disk_has_unresolved_keyring_sentinel
Returns true when load_config has no resolved AuthConfig::Bearer (etc.) but config.json on disk still contains KEYRING_SECRET_PLACEHOLDER (OS keyring could not supply the secret).
is_keyring_placeholder
Returns true if s is the sentinel written to disk when the secret lives in the keyring.
keyring_store
Store a secret in the OS keyring under the romm-cli service 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 /api suffix.
openapi_cache_path
Where the OpenAPI spec is cached (.../romm-cli/openapi.json).
persist_user_config
Persists the user configuration to config.json and stores secrets in the OS keyring.
read_user_config_json_from_disk
Reads config.json from 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-cli under the OS config dir).
user_config_json_path
Path to the user-level config.json file (.../romm-cli/config.json).