Configuration
config ¶
Configuration file support for eos-downloader.
This module provides optional TOML configuration file loading for the ardl CLI.
The configuration file allows users to set default values for CLI options,
following a dotfiles/chezmoi approach.
Priority order (highest to lowest):
1. CLI options
2. Environment variables (ARISTA_*)
3. Configuration file
4. Click defaults
Search paths (first found wins):
1. ~/.eos-downloader.toml
2. $XDG_CONFIG_HOME/eos-downloader/config.toml
(defaults to ~/.config/eos-downloader/config.toml)
Functions:
| Name | Description |
|---|---|
find_config_file |
Search for the configuration file in standard locations |
load_config |
Parse a TOML configuration file |
config_to_default_map |
Transform config dict into Click’s |
get_default_map |
Combine find + load + transform in one call |
generate_template |
Generate a commented TOML template with all available options |
config_to_default_map ¶
config_to_default_map(
config: Dict[str, Any],
) -> Dict[str, Any]
Transform a parsed config dict into Click’s default_map format.
The config structure follows the CLI hierarchy::
[ardl] → root group options (token, log_level, ...)
[ardl.get.eos] → ``ardl get eos`` options
[ardl.info] → shared defaults for all ``ardl info`` subcommands
[ardl.info.latest] → ``ardl info latest`` specific options
Group-level defaults (e.g. [ardl.info]) are merged into each
subcommand within that group, with subcommand-specific values taking
precedence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Dict[str, Any]
|
Parsed TOML configuration dictionary. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Click-compatible |
Source code in eos_downloader/config.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
find_config_file ¶
find_config_file() -> Optional[Path]
Search for the configuration file in standard locations.
Returns:
| Type | Description |
|---|---|
Optional[Path]
|
Path to the first existing configuration file, or None if not found. |
Source code in eos_downloader/config.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
generate_template ¶
generate_template() -> str
Generate a commented TOML template with all available options.
Returns:
| Type | Description |
|---|---|
str
|
A TOML string with all options commented out and documented. |
Source code in eos_downloader/config.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
get_default_map ¶
get_default_map() -> Optional[Dict[str, Any]]
Find, load, and transform the configuration file into a default_map.
This is a convenience function combining :func:find_config_file,
:func:load_config, and :func:config_to_default_map.
Returns:
| Type | Description |
|---|---|
Optional[Dict[str, Any]]
|
Click-compatible |
Source code in eos_downloader/config.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
load_config ¶
load_config(path: Path) -> Dict[str, Any]
Parse a TOML configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the TOML configuration file. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Parsed configuration dictionary, or empty dict on error. |
Source code in eos_downloader/config.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |