VirtualMailManager/cli/subcommands.py
branchv0.6.x
changeset 539 5806fb74130b
parent 536 c340ba4bd544
child 542 c3b98364f03d
equal deleted inserted replaced
538:1f9ea5658627 539:5806fb74130b
    29     'Command', 'RunContext', 'cmd_map', 'usage', 'alias_add', 'alias_delete',
    29     'Command', 'RunContext', 'cmd_map', 'usage', 'alias_add', 'alias_delete',
    30     'alias_info', 'aliasdomain_add', 'aliasdomain_delete', 'aliasdomain_info',
    30     'alias_info', 'aliasdomain_add', 'aliasdomain_delete', 'aliasdomain_info',
    31     'aliasdomain_switch', 'catchall_add', 'catchall_info', 'catchall_delete',
    31     'aliasdomain_switch', 'catchall_add', 'catchall_info', 'catchall_delete',
    32     'config_get', 'config_set', 'configure',
    32     'config_get', 'config_set', 'configure',
    33     'domain_add', 'domain_delete',  'domain_info', 'domain_quota',
    33     'domain_add', 'domain_delete',  'domain_info', 'domain_quota',
    34     'domain_services', 'domain_transport', 'get_user', 'help_', 'list_domains',
    34     'domain_services', 'domain_transport', 'domain_note', 'get_user', 'help_',
    35     'list_pwschemes', 'relocated_add', 'relocated_delete', 'relocated_info',
    35     'list_domains', 'list_pwschemes', 'relocated_add', 'relocated_delete',
    36     'user_add', 'user_delete', 'user_info', 'user_name', 'user_password',
    36     'relocated_info', 'user_add', 'user_delete', 'user_info', 'user_name',
    37     'user_quota', 'user_services', 'user_transport', 'version',
    37     'user_password', 'user_quota', 'user_services', 'user_transport',
       
    38     'user_note', 'version',
    38 )
    39 )
    39 
    40 
    40 _ = lambda msg: msg
    41 _ = lambda msg: msg
    41 txt_wrpr = TextWrapper(width=get_winsize()[1] - 1)
    42 txt_wrpr = TextWrapper(width=get_winsize()[1] - 1)
    42 cmd_map = {}
    43 cmd_map = {}
   405             usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % force,
   406             usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % force,
   406                   ctx.scmd)
   407                   ctx.scmd)
   407         ctx.hdlr.domain_transport(ctx.args[2].lower(), ctx.args[3], force)
   408         ctx.hdlr.domain_transport(ctx.args[2].lower(), ctx.args[3], force)
   408 
   409 
   409 
   410 
       
   411 def domain_note(ctx):
       
   412     """update the note of the given domain"""
       
   413     if ctx.argc < 3:
       
   414         usage(EX_MISSING_ARGS, _(u'Missing domain name.'),
       
   415               ctx.scmd)
       
   416     elif ctx.argc < 4:
       
   417         note = None
       
   418     else:
       
   419         note = ' '.join(ctx.args[3:])
       
   420     ctx.hdlr.domain_note(ctx.args[2].lower(), note)
       
   421 
       
   422 
   410 def get_user(ctx):
   423 def get_user(ctx):
   411     """get the address of the user with the given UID"""
   424     """get the address of the user with the given UID"""
   412     if ctx.argc < 3:
   425     if ctx.argc < 3:
   413         usage(EX_MISSING_ARGS, _(u'Missing UID.'), ctx.scmd)
   426         usage(EX_MISSING_ARGS, _(u'Missing UID.'), ctx.scmd)
   414     _print_info(ctx, ctx.hdlr.user_by_uid(ctx.args[2]), _(u'Account'))
   427     _print_info(ctx, ctx.hdlr.user_by_uid(ctx.args[2]), _(u'Account'))
   607     elif ctx.argc < 4:
   620     elif ctx.argc < 4:
   608         password = None
   621         password = None
   609     else:
   622     else:
   610         password = ctx.args[3]
   623         password = ctx.args[3]
   611     ctx.hdlr.user_password(ctx.args[2].lower(), password)
   624     ctx.hdlr.user_password(ctx.args[2].lower(), password)
       
   625 
       
   626 
       
   627 def user_note(ctx):
       
   628     """update the note of the given address"""
       
   629     if ctx.argc < 3:
       
   630         usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'),
       
   631               ctx.scmd)
       
   632     elif ctx.argc < 4:
       
   633         note = None
       
   634     else:
       
   635         note = ' '.join(ctx.args[3:])
       
   636     ctx.hdlr.user_note(ctx.args[2].lower(), note)
   612 
   637 
   613 
   638 
   614 def user_quota(ctx):
   639 def user_quota(ctx):
   615     """update the quota limit for the given address"""
   640     """update the quota limit for the given address"""
   616     if ctx.argc < 3:
   641     if ctx.argc < 3:
   729                         _(u'enables the specified services and disables all '
   754                         _(u'enables the specified services and disables all '
   730                           u'not specified services')),
   755                           u'not specified services')),
   731     'usertransport': cmd('usertransport', 'ut', user_transport,
   756     'usertransport': cmd('usertransport', 'ut', user_transport,
   732                          'address transport | address default',
   757                          'address transport | address default',
   733                          _(u'update the transport of the given address')),
   758                          _(u'update the transport of the given address')),
       
   759     'usernote': cmd('usernote', 'uo', user_note,
       
   760                     'address note',
       
   761                     _(u'update the note of the given address')),
   734     # Alias commands
   762     # Alias commands
   735     'aliasadd': cmd('aliasadd', 'aa', alias_add, 'address destination ...',
   763     'aliasadd': cmd('aliasadd', 'aa', alias_add, 'address destination ...',
   736                     _(u'create a new alias e-mail address with one or more '
   764                     _(u'create a new alias e-mail address with one or more '
   737                       u'destinations')),
   765                       u'destinations')),
   738     'aliasdelete': cmd('aliasdelete', 'ad', alias_delete,
   766     'aliasdelete': cmd('aliasdelete', 'ad', alias_delete,
   778                           _(u'enables the specified services and disables all '
   806                           _(u'enables the specified services and disables all '
   779                             u'not specified services of the given domain')),
   807                             u'not specified services of the given domain')),
   780     'domaintransport': cmd('domaintransport', 'dt', domain_transport,
   808     'domaintransport': cmd('domaintransport', 'dt', domain_transport,
   781                            'fqdn transport [force]',
   809                            'fqdn transport [force]',
   782                            _(u'update the transport of the specified domain')),
   810                            _(u'update the transport of the specified domain')),
       
   811     'domainnote': cmd('domainnote', 'do', domain_note,
       
   812                       'fqdn note',
       
   813                       _(u'update the note of the given domain')),
   783     'listdomains': cmd('listdomains', 'ld', list_domains, '[pattern]',
   814     'listdomains': cmd('listdomains', 'ld', list_domains, '[pattern]',
   784                       _(u'list all domains or search for domains by pattern')),
   815                       _(u'list all domains or search for domains by pattern')),
   785     # Relocated commands
   816     # Relocated commands
   786     'relocatedadd': cmd('relocatedadd', 'ra', relocated_add,
   817     'relocatedadd': cmd('relocatedadd', 'ra', relocated_add,
   787                         'address newaddress',
   818                         'address newaddress',