MCPcopy
hub / github.com/AstrBotDevs/AstrBot / get_config

Function get_config

astrbot/cli/commands/cmd_conf.py:212–240  ·  view source on GitHub ↗

Get the value of a config item. If no key is provided, show all configurable items

(key: str | None = None)

Source from the content-addressed store, hash-verified

210@conf.command(name="get")
211@click.argument("key", required=False)
212def 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

Callers 1

_get_context_configMethod · 0.85

Calls 2

_load_configFunction · 0.85
_get_nested_itemFunction · 0.85

Tested by

no test coverage detected