VirtualMailManager/cli/subcommands.py
changeset 608 0ed93eb8b364
parent 607 46454ff9d441
child 609 56ec275911f2
equal deleted inserted replaced
607:46454ff9d441 608:0ed93eb8b364
   214 
   214 
   215 
   215 
   216 def catchall_delete(ctx):
   216 def catchall_delete(ctx):
   217     """delete the specified destination or all of the catchall destination"""
   217     """delete the specified destination or all of the catchall destination"""
   218     if ctx.argc < 3:
   218     if ctx.argc < 3:
   219         usage(EX_MISSING_ARGS, _(u'Missing domain.'), ctx.scmd)
   219         usage(EX_MISSING_ARGS, _(u'Missing domain name.'), ctx.scmd)
   220     elif ctx.argc < 4:
   220     elif ctx.argc < 4:
   221         ctx.hdlr.catchall_delete(ctx.args[2].lower())
   221         ctx.hdlr.catchall_delete(ctx.args[2].lower())
   222     else:
   222     else:
   223         ctx.hdlr.catchall_delete(ctx.args[2].lower(), ctx.args[3])
   223         ctx.hdlr.catchall_delete(ctx.args[2].lower(), ctx.args[3])
   224 
   224 
   225 
   225 
   226 def catchall_info(ctx):
   226 def catchall_info(ctx):
   227     """show the catchall destination(s) of the specified domain"""
   227     """show the catchall destination(s) of the specified domain"""
   228     if ctx.argc < 3:
   228     if ctx.argc < 3:
   229         usage(EX_MISSING_ARGS, _(u'Missing domain.'), ctx.scmd)
   229         usage(EX_MISSING_ARGS, _(u'Missing domain name.'), ctx.scmd)
   230     address = ctx.args[2].lower()
   230     address = ctx.args[2].lower()
   231     _print_catchall_info(address, ctx.hdlr.catchall_info(address))
   231     _print_catchall_info(address, ctx.hdlr.catchall_info(address))
   232 
   232 
   233 
   233 
   234 def config_get(ctx):
   234 def config_get(ctx):
   256               ctx.scmd)
   256               ctx.scmd)
   257     ctx.hdlr.cfg_set(ctx.args[2].lower(), ctx.args[3])
   257     ctx.hdlr.cfg_set(ctx.args[2].lower(), ctx.args[3])
   258 
   258 
   259 
   259 
   260 def configure(ctx):
   260 def configure(ctx):
   261     """start interactive configuration modus"""
   261     """start interactive configuration mode"""
   262     if ctx.argc < 3:
   262     if ctx.argc < 3:
   263         ctx.hdlr.configure()
   263         ctx.hdlr.configure()
   264     else:
   264     else:
   265         ctx.hdlr.configure(ctx.args[2].lower())
   265         ctx.hdlr.configure(ctx.args[2].lower())
   266 
   266 
   799     'userdelete': cmd('userdelete', 'ud', user_delete, 'address [force]',
   799     'userdelete': cmd('userdelete', 'ud', user_delete, 'address [force]',
   800                       _(u'delete the specified user')),
   800                       _(u'delete the specified user')),
   801     'userinfo': cmd('userinfo', 'ui', user_info, 'address [details]',
   801     'userinfo': cmd('userinfo', 'ui', user_info, 'address [details]',
   802                     _(u'display information about the given address')),
   802                     _(u'display information about the given address')),
   803     'username': cmd('username', 'un', user_name, 'address [name]',
   803     'username': cmd('username', 'un', user_name, 'address [name]',
   804                     _(u'set or update the real name for an address')),
   804                     _(u'set, update or delete the real name for an address')),
   805     'userpassword': cmd('userpassword', 'up', user_password,
   805     'userpassword': cmd('userpassword', 'up', user_password,
   806                         'address [password]',
   806                         'address [password]',
   807                         _(u'update the password for the given address')),
   807                         _(u'update the password for the given address')),
   808     'userquota': cmd('userquota', 'uq', user_quota,
   808     'userquota': cmd('userquota', 'uq', user_quota,
   809                      'address storage [messages] | address domain',
   809                      'address storage [messages] | address domain',
   814                           u'not specified services')),
   814                           u'not specified services')),
   815     'usertransport': cmd('usertransport', 'ut', user_transport,
   815     'usertransport': cmd('usertransport', 'ut', user_transport,
   816                          'address transport | address domain',
   816                          'address transport | address domain',
   817                          _(u'update the transport of the given address')),
   817                          _(u'update the transport of the given address')),
   818     'usernote': cmd('usernote', 'uo', user_note, 'address [note]',
   818     'usernote': cmd('usernote', 'uo', user_note, 'address [note]',
   819                     _(u'update the note of the given address')),
   819                     _(u'set, update or delete the note of the given address')),
   820     # Alias commands
   820     # Alias commands
   821     'aliasadd': cmd('aliasadd', 'aa', alias_add, 'address destination ...',
   821     'aliasadd': cmd('aliasadd', 'aa', alias_add, 'address destination ...',
   822                     _(u'create a new alias e-mail address with one or more '
   822                     _(u'create a new alias e-mail address with one or more '
   823                       u'destinations')),
   823                       u'destinations')),
   824     'aliasdelete': cmd('aliasdelete', 'ad', alias_delete,
   824     'aliasdelete': cmd('aliasdelete', 'ad', alias_delete,
   865                             u'not specified services of the given domain')),
   865                             u'not specified services of the given domain')),
   866     'domaintransport': cmd('domaintransport', 'dt', domain_transport,
   866     'domaintransport': cmd('domaintransport', 'dt', domain_transport,
   867                            'fqdn transport [force]',
   867                            'fqdn transport [force]',
   868                            _(u'update the transport of the specified domain')),
   868                            _(u'update the transport of the specified domain')),
   869     'domainnote': cmd('domainnote', 'do', domain_note, 'fqdn [note]',
   869     'domainnote': cmd('domainnote', 'do', domain_note, 'fqdn [note]',
   870                       _(u'update the note of the given domain')),
   870                      _(u'set, update or delete the note of the given domain')),
   871     # List commands
   871     # List commands
   872     'listdomains': cmd('listdomains', 'ld', list_domains, '[pattern]',
   872     'listdomains': cmd('listdomains', 'ld', list_domains, '[pattern]',
   873                       _(u'list all domains or search for domains by pattern')),
   873                       _(u'list all domains or search for domains by pattern')),
   874     'listaddresses': cmd('listaddresses', 'll', list_addresses, '[pattern]',
   874     'listaddresses': cmd('listaddresses', 'll', list_addresses, '[pattern]',
   875                       _(u'list all addresses or search for addresses by pattern')),
   875                       _(u'list all addresses or search for addresses by pattern')),
   876     'listusers': cmd('listusers', 'lu', list_users, '[pattern]',
   876     'listusers': cmd('listusers', 'lu', list_users, '[pattern]',
   877                       _(u'list all user accounts or search for accounts by pattern')),
   877                       _(u'list all user accounts or search for accounts by pattern')),
   878     'listaliases': cmd('listaliases', 'la', list_aliases, '[pattern]',
   878     'listaliases': cmd('listaliases', 'la', list_aliases, '[pattern]',
   879                       _(u'list all aliases or search for aliases by pattern')),
   879                       _(u'list all aliases or search for aliases by pattern')),
   880     'listrelocated': cmd('listrelocated', 'lr', list_relocated, '[pattern]',
   880     'listrelocated': cmd('listrelocated', 'lr', list_relocated, '[pattern]',
   881                       _(u'list all relocated entries or search for entries by pattern')),
   881                          _(u'list all relocated users or search for relocated '
       
   882                            u'users by pattern')),
   882     # Relocated commands
   883     # Relocated commands
   883     'relocatedadd': cmd('relocatedadd', 'ra', relocated_add,
   884     'relocatedadd': cmd('relocatedadd', 'ra', relocated_add,
   884                         'address newaddress',
   885                         'address newaddress',
   885                         _(u'create a new record for a relocated user')),
   886                         _(u'create a new record for a relocated user')),
   886     'relocateddelete': cmd('relocateddelete', 'rd', relocated_delete,
   887     'relocateddelete': cmd('relocateddelete', 'rd', relocated_delete,
   892     'configget': cmd('configget', 'cg', config_get, 'option',
   893     'configget': cmd('configget', 'cg', config_get, 'option',
   893                      _('show the actual value of the configuration option')),
   894                      _('show the actual value of the configuration option')),
   894     'configset': cmd('configset', 'cs', config_set, 'option value',
   895     'configset': cmd('configset', 'cs', config_set, 'option value',
   895                       _('set a new value for the configuration option')),
   896                       _('set a new value for the configuration option')),
   896     'configure': cmd('configure', 'cf', configure, '[section]',
   897     'configure': cmd('configure', 'cf', configure, '[section]',
   897                      _(u'start interactive configuration modus')),
   898                      _(u'start interactive configuration mode')),
   898     'listpwschemes': cmd('listpwschemes', 'lp', list_pwschemes, '',
   899     'listpwschemes': cmd('listpwschemes', 'lp', list_pwschemes, '',
   899                          _(u'lists all usable password schemes and password '
   900                          _(u'lists all usable password schemes and password '
   900                            u'encoding suffixes')),
   901                            u'encoding suffixes')),
   901     'help': cmd('help', 'h', help_, '[subcommand]',
   902     'help': cmd('help', 'h', help_, '[subcommand]',
   902                 _(u'show a help overview or help for the given subcommand')),
   903                 _(u'show a help overview or help for the given subcommand')),
  1018 
  1019 
  1019 def _print_catchall_info(domain, destinations):
  1020 def _print_catchall_info(domain, destinations):
  1020     """Print the catchall destinations of a domain"""
  1021     """Print the catchall destinations of a domain"""
  1021     title = _(u'Catch-all information')
  1022     title = _(u'Catch-all information')
  1022     w_std(title, u'-' * len(title))
  1023     w_std(title, u'-' * len(title))
  1023     w_std(_(u'\tMail to unknown localparts in domain %s will be sent to:')
  1024     w_std(_(u'\tMail to unknown local-parts in domain %s will be sent to:')
  1024           % domain)
  1025           % domain)
  1025     w_std(*(u'\t     * %s' % dest for dest in destinations))
  1026     w_std(*(u'\t     * %s' % dest for dest in destinations))
  1026     print
  1027     print
  1027 
  1028 
  1028 
  1029 
  1062 
  1063 
  1063 def _print_address_list(which, dids, addresses, matching):
  1064 def _print_address_list(which, dids, addresses, matching):
  1064     """Print a list of (matching) addresses."""
  1065     """Print a list of (matching) addresses."""
  1065     _trans = { TYPE_ACCOUNT                  : _('user accounts')
  1066     _trans = { TYPE_ACCOUNT                  : _('user accounts')
  1066              , TYPE_ALIAS                    : _('aliases')
  1067              , TYPE_ALIAS                    : _('aliases')
  1067              , TYPE_RELOCATED                : _('relocated entries')
  1068              , TYPE_RELOCATED                : _('relocated users')
  1068              , TYPE_ACCOUNT | TYPE_ALIAS
  1069              , TYPE_ACCOUNT | TYPE_ALIAS
  1069                  : _('user accounts and aliases')
  1070                  : _('user accounts and aliases')
  1070              , TYPE_ACCOUNT | TYPE_RELOCATED
  1071              , TYPE_ACCOUNT | TYPE_RELOCATED
  1071                  : _('user accounts and relocated entries')
  1072                  : _('user accounts and relocated users')
  1072              , TYPE_ALIAS | TYPE_RELOCATED
  1073              , TYPE_ALIAS | TYPE_RELOCATED
  1073                  : _('aliases and relocated entries')
  1074                  : _('aliases and relocated users')
  1074              , TYPE_ACCOUNT | TYPE_ALIAS | TYPE_RELOCATED : _('addresses')
  1075              , TYPE_ACCOUNT | TYPE_ALIAS | TYPE_RELOCATED : _('addresses')
  1075              }
  1076              }
  1076     try:
  1077     try:
  1077         if matching:
  1078         if matching:
  1078             title = _(u'Matching %s') % _trans[which]
  1079             title = _(u'Matching %s') % _trans[which]