From 6b8af2413e47fc13796ea061ff759d7c1ca74c5c Mon Sep 17 00:00:00 2001
From: mathieui <mathieui@mathieui.net>
Date: Mon, 20 Oct 2014 22:54:00 +0200
Subject: Fix #2713 (make /set <option> return the value of the option)

Should work for any case (plugin, different section, etc)
---
 src/core/commands.py | 38 ++++++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 8 deletions(-)

(limited to 'src')

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)
 
-- 
cgit v1.2.3