From 73e93285dbd3ef69a23668f3582a1980f72f2a98 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sun, 18 May 2025 19:51:26 +0200 Subject: [PATCH] CLI: add 'clearconfig' command --- electrum/commands.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/electrum/commands.py b/electrum/commands.py index d970dfdda..098dcf6b6 100644 --- a/electrum/commands.py +++ b/electrum/commands.py @@ -385,14 +385,7 @@ class Commands(Logger): pass return 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. - """ + def _setconfig(self, key, value): value = self._setconfig_normalize_value(key, value) if self.daemon and key == SimpleConfig.RPC_USERNAME.key(): self.daemon.commands_server.rpc_user = value @@ -404,6 +397,26 @@ class Commands(Logger): cv = self.config.cv.from_key(key) 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('') async def listconfig(self): """Returns the list of all configuration variables. """