summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-10-20 22:54:00 +0200
committermathieui <mathieui@mathieui.net>2014-10-20 22:54:00 +0200
commit6b8af2413e47fc13796ea061ff759d7c1ca74c5c (patch)
treeaa821968c795301381c1c11762111193a055c296 /src
parent7bc5d0de663ccb71d70855999188b4ca2b61869a (diff)
downloadpoezio-6b8af2413e47fc13796ea061ff759d7c1ca74c5c.tar.gz
poezio-6b8af2413e47fc13796ea061ff759d7c1ca74c5c.tar.bz2
poezio-6b8af2413e47fc13796ea061ff759d7c1ca74c5c.tar.xz
poezio-6b8af2413e47fc13796ea061ff759d7c1ca74c5c.zip
Fix #2713 (make /set <option> return the value of the option)
Should work for any case (plugin, different section, etc)
Diffstat (limited to 'src')
-rw-r--r--src/core/commands.py38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/core/commands.py b/src/core/commands.py
index daf420fb..b44f3483 100644
--- a/src/core/commands.py
+++ b/src/core/commands.py
@@ -586,17 +586,36 @@ def command_remove_bookmark(self, arg=''):
def command_set(self, arg):
"""
- /set [module|][section] <option> <value>
+ /set [module|][section] <option> [value]
"""
args = common.shell_split(arg)
- if len(args) != 2 and len(args) != 3:
- self.command_help('set')
- return
- if len(args) == 2:
+ if len(args) == 1:
option = args[0]
- value = args[1]
- info = config.set_and_save(option, value)
- self.trigger_configuration_change(option, value)
+ value = config.get(option)
+ info = ('%s=%s' % (option, value), 'Info')
+ elif len(args) == 2:
+ if '|' in args[0]:
+ plugin_name, section = args[0].split('|')[:2]
+ if not section:
+ section = plugin_name
+ option = args[1]
+ if not plugin_name in self.plugin_manager.plugins:
+ return
+ plugin = self.plugin_manager.plugins[plugin_name]
+ value = plugin.config.get(option, default='', section=section)
+ info = ('%s=%s' % (option, value), 'Info')
+ else:
+ possible_section = args[0]
+ if config.has_section(possible_section):
+ section = possible_section
+ option = args[1]
+ value = config.get(option, section=section)
+ info = ('%s=%s' % (option, value), 'Info')
+ else:
+ option = args[0]
+ value = args[1]
+ info = config.set_and_save(option, value)
+ self.trigger_configuration_change(option, value)
elif len(args) == 3:
if '|' in args[0]:
plugin_name, section = args[0].split('|')[:2]
@@ -614,6 +633,9 @@ def command_set(self, arg):
value = args[2]
info = config.set_and_save(option, value, section)
self.trigger_configuration_change(option, value)
+ else:
+ self.command_help('set')
+ return
self.call_for_resize()
self.information(*info)