]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Improve confighelp output
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 22 Apr 2017 22:08:06 +0000 (23:08 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 22 Apr 2017 22:08:06 +0000 (23:08 +0100)
src/rspamadm/confighelp.lua

index 91da3177dec5f85345be6bb4a8369f5fe83f8e79..e95dd0b36871bc13d62f43b76f423ca20551349e 100644 (file)
@@ -64,16 +64,11 @@ local function print_help(key, value, tabs)
 
   if not opts['short'] then
     if value['data'] then
-      print(string.format('%s\tDescription: %s', tabs, value['data']))
-    end
-    if not opts['no-examples'] and value['example'] then
-      print(string.format('%s\tExample: %s', tabs, value['example']))
+      local nv = string.match(value['data'], '^#%s*(.*)%s*$') or value.data
+      print(string.format('%s\tDescription: %s', tabs, nv))
     end
     if value['type'] then
       print(string.format('%s\tType: %s', tabs, value['type']))
-      if value['type'] == 'object' then
-        print('')
-      end
     end
     if type(value['required']) == 'boolean' then
       if value['required'] then
@@ -87,6 +82,13 @@ local function print_help(key, value, tabs)
     if value['default'] then
       print(string.format('%s\tDefault: %s', tabs, value['default']))
     end
+    if not opts['no-examples'] and value['example'] then
+      local nv = string.match(value['example'], '^%s*(.*[^%s])%s*$') or value.example
+      print(string.format('%s\tExample:\n%s', tabs, nv))
+    end
+    if value.type and value.type == 'object' then
+      print('')
+    end
   end
 
   local sorted = sort_values(value)