Get the value of a config item. If no key is provided, show all configurable items
(key: str | None = None)
| 210 | @conf.command(name="get") |
| 211 | @click.argument("key", required=False) |
| 212 | def get_config(key: str | None = None) -> None: |
| 213 | """Get the value of a config item. If no key is provided, show all configurable items""" |
| 214 | config = _load_config() |
| 215 | |
| 216 | if key: |
| 217 | if key not in CONFIG_VALIDATORS: |
| 218 | raise click.ClickException(f"Unsupported config key: {key}") |
| 219 | |
| 220 | try: |
| 221 | value = _get_nested_item(config, key) |
| 222 | if key == "dashboard.password": |
| 223 | value = "********" |
| 224 | click.echo(f"{key}: {value}") |
| 225 | except KeyError: |
| 226 | raise click.ClickException(f"Unknown config key: {key}") |
| 227 | except Exception as e: |
| 228 | raise click.UsageError(f"Failed to get config: {e!s}") |
| 229 | else: |
| 230 | click.echo("Current config:") |
| 231 | for key in CONFIG_VALIDATORS: |
| 232 | try: |
| 233 | value = ( |
| 234 | "********" |
| 235 | if key == "dashboard.password" |
| 236 | else _get_nested_item(config, key) |
| 237 | ) |
| 238 | click.echo(f" {key}: {value}") |
| 239 | except (KeyError, TypeError): |
| 240 | pass |
no test coverage detected