VirtualMailManager/cli/subcommands.py
branchv0.6.x
changeset 420 d4a341248500
parent 418 542a4d23a9f0
child 423 a43a2e20de71
equal deleted inserted replaced
419:241b192bfcc8 420:d4a341248500
    34     'user_quota', 'user_transport', 'version',
    34     'user_quota', 'user_transport', 'version',
    35 )
    35 )
    36 
    36 
    37 _ = lambda msg: msg
    37 _ = lambda msg: msg
    38 txt_wrpr = TextWrapper(width=get_winsize()[1] - 1)
    38 txt_wrpr = TextWrapper(width=get_winsize()[1] - 1)
       
    39 cmd_map = {}
    39 
    40 
    40 
    41 
    41 class Command(object):
    42 class Command(object):
    42     """Container class for command information."""
    43     """Container class for command information."""
    43     __slots__ = ('name', 'alias', 'func', 'args', 'descr')
    44     __slots__ = ('name', 'alias', 'func', 'args', 'descr')
   624             strptime(__date__, '%Y-%m-%d')).decode(ENCODING, 'replace'),
   625             strptime(__date__, '%Y-%m-%d')).decode(ENCODING, 'replace'),
   625         os.sys.version.split()[0], _(u'on'), os.uname()[0],
   626         os.sys.version.split()[0], _(u'on'), os.uname()[0],
   626         __copyright__, prog,
   627         __copyright__, prog,
   627         _(u'is free software and comes with ABSOLUTELY NO WARRANTY.')))
   628         _(u'is free software and comes with ABSOLUTELY NO WARRANTY.')))
   628 
   629 
   629 cmd = Command
   630 
   630 cmd_map = {  # {{{
   631 def update_cmd_map():
       
   632     """Update the cmd_map, after gettext's _ was installed."""
       
   633     cmd = Command
       
   634     cmd_map.update({
   631     # Account commands
   635     # Account commands
   632     'getuser': cmd('getuser', 'gu', get_user, _(u'uid'),
   636     'getuser': cmd('getuser', 'gu', get_user, _(u'uid'),
   633                    _(u'get the address of the user with the given UID')),
   637                    _(u'get the address of the user with the given UID')),
   634     'useradd': cmd('useradd', 'ua', user_add, _(u'address [password]'),
   638     'useradd': cmd('useradd', 'ua', user_add, _(u'address [password]'),
   635                    _(u'create a new e-mail user with the given address')),
   639                    _(u'create a new e-mail user with the given address')),
   636     'userdelete': cmd('userdelete', 'ud', user_delete,
   640     'userdelete': cmd('userdelete', 'ud', user_delete,
   637                       _(u'address') + ' [force]', 
   641                       _(u'address') + ' [force]',
   638                       _(u'delete the specified user')),
   642                       _(u'delete the specified user')),
   639     'userdisable': cmd('userdisable', 'u0', user_disable,
   643     'userdisable': cmd('userdisable', 'u0', user_disable,
   640                        _(u'address [service ...]'),
   644                        _(u'address [service ...]'),
   641                        _(u'deactivate all/the given service(s) for a user')),
   645                        _(u'deactivate all/the given service(s) for a user')),
   642     'userenable': cmd('userenable', 'u1', user_enable,
   646     'userenable': cmd('userenable', 'u1', user_enable,
   712                      _(u'start interactive configuration modus')),
   716                      _(u'start interactive configuration modus')),
   713     'help': cmd('help', 'h', help_, _(u'[subcommand]'),
   717     'help': cmd('help', 'h', help_, _(u'[subcommand]'),
   714                 _(u'show a help overview or help for the given subcommand')),
   718                 _(u'show a help overview or help for the given subcommand')),
   715     'version': cmd('version', 'v', version, '',
   719     'version': cmd('version', 'v', version, '',
   716                    _(u'show version and copyright information')),
   720                    _(u'show version and copyright information')),
   717 }  # }}}
   721     })
   718 
   722 
   719 
   723 
   720 def _get_order(ctx):
   724 def _get_order(ctx):
   721     """returns a tuple with (key, 1||0) tuples. Used by functions, which
   725     """returns a tuple with (key, 1||0) tuples. Used by functions, which
   722     get a dict from the handler."""
   726     get a dict from the handler."""