Config¶
cxg.config
¶
YAML configuration file support for cxg CLI.
DefaultsConfig
¶
Bases: BaseModel
Default filter values applied when CLI flags are omitted.
Source code in src/cxg/config.py
DisplayConfig
¶
Bases: BaseModel
Display preferences for list output.
Source code in src/cxg/config.py
CacheConfig
¶
Bases: BaseModel
Cache behavior settings.
Source code in src/cxg/config.py
ApiConfig
¶
CxgConfig
¶
Bases: BaseModel
Top-level cxg configuration.
Source code in src/cxg/config.py
user_config_path()
¶
Return the user config file path, respecting CXG_CONFIG_FILE env var.
Source code in src/cxg/config.py
project_config_path()
¶
Walk up from cwd looking for cxg.yml.
Returns None if no project config is found.
Source code in src/cxg/config.py
config_path_for_level(level)
¶
Return the config file path for a given level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
str
|
Either "user" or "project". |
required |
Returns:
| Type | Description |
|---|---|
Path | None
|
The path, or None if no project config is found. |
Source code in src/cxg/config.py
schema_path()
¶
load_config()
¶
Load, merge, and validate config files from all levels.
Precedence (highest to lowest): project config > user config > defaults. The result is cached for the lifetime of the process.
Source code in src/cxg/config.py
load_config_raw(level=None)
¶
Load a config file as a plain dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
str | None
|
"user" or "project" to read a specific file. None returns the merged config across all levels. |
None
|
Source code in src/cxg/config.py
save_config(data, level='user')
¶
Atomically write config data as YAML.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
The config data to write. |
required |
level
|
str
|
"user" or "project". Project level writes to cwd. |
'user'
|
Source code in src/cxg/config.py
get_value(data, dotted_key)
¶
Traverse a nested dict by dot-separated key path.
Raises KeyError if any segment is missing.
Source code in src/cxg/config.py
set_value(data, dotted_key, raw_value)
¶
Set a value in a nested dict, creating intermediate dicts as needed.
List-valued keys (defaults.*) are split on commas. Integer-valued keys (cache.ttl, display.limit) are coerced to int.