1
0

CLI: add 'clearconfig' command

This commit is contained in:
ThomasV
2025-05-18 19:51:26 +02:00
parent cbe0244d66
commit 73e93285db

View File

@@ -385,14 +385,7 @@ class Commands(Logger):
pass pass
return value return value
@command('') def _setconfig(self, key, value):
async def setconfig(self, key, value):
"""
Set a configuration variable.
arg:str:key:name of the configuration variable
arg:str:value:value. may be a string or a Python expression.
"""
value = self._setconfig_normalize_value(key, value) value = self._setconfig_normalize_value(key, value)
if self.daemon and key == SimpleConfig.RPC_USERNAME.key(): if self.daemon and key == SimpleConfig.RPC_USERNAME.key():
self.daemon.commands_server.rpc_user = value self.daemon.commands_server.rpc_user = value
@@ -404,6 +397,26 @@ class Commands(Logger):
cv = self.config.cv.from_key(key) cv = self.config.cv.from_key(key)
cv.set(value) cv.set(value)
@command('')
async def setconfig(self, key, value):
"""
Set a configuration variable.
arg:str:key:name of the configuration variable
arg:str:value:value. may be a string or a Python expression.
"""
self._setconfig(key, value)
@command('')
async def clearconfig(self, key):
"""
Clear a configuration variable.
The variable will be reset to its default value.
arg:str:key:name of the configuration variable
"""
self._setconfig(key, None)
@command('') @command('')
async def listconfig(self): async def listconfig(self):
"""Returns the list of all configuration variables. """ """Returns the list of all configuration variables. """