VMM/cli/subcommands: Added subcommands configget and configset. v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Fri, 06 Aug 2010 22:34:46 +0000
branchv0.6.x
changeset 345 f8d5c8bb8bce
parent 344 0d2430dc6ef8
child 346 95d45e4ec1a6
VMM/cli/subcommands: Added subcommands configget and configset.
VirtualMailManager/cli/subcommands.py
man/de/man1/vmm.1.rst
man/man1/vmm.1.rst
--- a/VirtualMailManager/cli/subcommands.py	Fri Aug 06 06:14:04 2010 +0000
+++ b/VirtualMailManager/cli/subcommands.py	Fri Aug 06 22:34:46 2010 +0000
@@ -17,6 +17,7 @@
 from VirtualMailManager import ENCODING
 from VirtualMailManager.account import SERVICES
 from VirtualMailManager.cli import get_winsize, prog, w_err, w_std
+from VirtualMailManager.common import version_str
 from VirtualMailManager.constants import __copyright__, __date__, \
      __version__, ACCOUNT_EXISTS, ALIAS_EXISTS, ALIASDOMAIN_ISDOMAIN, \
      DOMAIN_ALIAS_EXISTS, INVALID_ARGUMENT, EX_MISSING_ARGS, RELOCATED_EXISTS
@@ -25,11 +26,11 @@
 __all__ = (
     'Command', 'RunContext', 'cmd_map', 'usage', 'alias_add', 'alias_delete',
     'alias_info', 'aliasdomain_add', 'aliasdomain_delete', 'aliasdomain_info',
-    'aliasdomain_switch', 'configure', 'domain_add', 'domain_delete',
-    'domain_info', 'domain_transport', 'get_user', 'help_', 'list_domains',
-    'relocated_add', 'relocated_delete', 'relocated_info', 'user_add',
-    'user_delete', 'user_disable', 'user_enable', 'user_info', 'user_name',
-    'user_password', 'user_transport', 'version',
+    'aliasdomain_switch', 'config_get', 'config_set', 'configure',
+    'domain_add', 'domain_delete',  'domain_info', 'domain_transport',
+    'get_user', 'help_', 'list_domains', 'relocated_add', 'relocated_delete',
+    'relocated_info', 'user_add', 'user_delete', 'user_disable', 'user_enable',
+    'user_info', 'user_name', 'user_password', 'user_transport', 'version',
 )
 
 _ = lambda msg: msg
@@ -169,6 +170,27 @@
     ctx.hdlr.aliasdomain_switch(ctx.args[2].lower(), ctx.args[3].lower())
 
 
+def config_get(ctx):
+    """show the actual value of the configuration option"""
+    if ctx.argc < 3:
+        usage(EX_MISSING_ARGS, _(u"Missing option name."), ctx.scmd)
+    option = ctx.args[2].lower()
+    if option != 'misc.dovecot_version':
+        w_std('%s = %s' % (option, ctx.cget(option)))
+    else:
+        w_std('%s = %s' % (option, version_str(ctx.cget(option))))
+
+
+def config_set(ctx):
+    """set a new value for the configuration option"""
+    if ctx.argc < 3:
+        usage(EX_MISSING_ARGS, _(u'Missing option and new value.'), ctx.scmd)
+    if ctx.argc < 4:
+        usage(EX_MISSING_ARGS, _(u'Missing new configuration value.'),
+              ctx.scmd)
+    ctx.hdlr.cfg_set(ctx.args[2].lower(), ctx.args[3])
+
+
 def configure(ctx):
     """start interactive configuration modus"""
     if ctx.argc < 3:
@@ -577,6 +599,10 @@
     'relocatedinfo': cmd('relocatedinfo', 'ri', relocated_info, 'address',
                          _(u'print information about a relocated user')),
     # cli commands
+    'configget': cmd('configget', 'cg', config_get, 'option',
+                     _('show the actual value of the configuration option')),
+    'configset': cmd('configset', 'cs', config_set, 'option value',
+                      _('set a new value for the configuration option')),
     'configure': cmd('configure', 'cf', configure, '[section]',
                      _(u'start interactive configuration modus')),
     'help': cmd('help', 'h', help_, '[subcommand]',
--- a/man/de/man1/vmm.1.rst	Fri Aug 06 06:14:04 2010 +0000
+++ b/man/de/man1/vmm.1.rst	Fri Aug 06 22:34:46 2010 +0000
@@ -38,6 +38,28 @@
 
 ALLGEMEINE UNTERBEFEHLE
 -----------------------
+.. _configget:
+
+``configget (cg) Option``
+ Dieser Unterbefehl wird verwendet, um den aktuellen Wert der übergebenen
+ *Option* anzuzeigen. Die *Option* wird in der Form *Sektion*\ **.**\ *Option*
+ angegeben. Zum Beispiel: **misc.transport**.
+
+.. _configset:
+
+``configset (cs) Option Wert``
+  Verwenden Sie diesen Unterbefehl, um einer einzelnen Konfigurations-*Option*
+  einen neuen *Wert* zuzuweisen. Die *Option* wird dabei in der Form
+  *Sektion*\ **.**\ *Option* angegeben. *Wert* ist der neue Wert der *Option*.
+
+  Beispiel::
+
+    vmm configget misc.transport
+    misc.transport = dovecot:
+    vmm configset misc.transport lmtp:unix:private/dovecot-lmtp
+    vmm cg misc.transport
+    misc.transport = lmtp:unix:private/dovecot-lmtp
+
 .. _configure:
 
 ``configure (cf) [ Sektion ]``
--- a/man/man1/vmm.1.rst	Fri Aug 06 06:14:04 2010 +0000
+++ b/man/man1/vmm.1.rst	Fri Aug 06 22:34:46 2010 +0000
@@ -36,6 +36,28 @@
 
 GENERAL SUBCOMMANDS
 -------------------
+.. _configget:
+
+``configget (cg) option``
+  This subcommand is used to display the actual value of the given
+  configuration *option*. The option has to be written as
+  *section*\ **.**\ *option*, e.g. **misc.transport**.
+
+.. _configset:
+
+``configset (cs) option value``
+  Use this subcommand to set/update a single configuration option. *option*
+  is the configuration option, written as *section*\ **.**\ *option*. *value*
+  is the *option*'s new value.
+
+  Example::
+
+    vmm configget misc.transport
+    misc.transport = dovecot:
+    vmm configset misc.transport lmtp:unix:private/dovecot-lmtp
+    vmm cg misc.transport
+    misc.transport = lmtp:unix:private/dovecot-lmtp
+
 .. _configure:
 
 ``configure (cf) [ section ]``