mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Argument list for user category
This commit is contained in:
parent
76f85e8fda
commit
df2a8d9ad1
1 changed files with 99 additions and 21 deletions
120
yunohost
120
yunohost
|
@ -74,7 +74,7 @@ action_dict = {
|
||||||
'general_arguments' : {
|
'general_arguments' : {
|
||||||
'-v' : {
|
'-v' : {
|
||||||
'full' : '--version',
|
'full' : '--version',
|
||||||
'help' : _('Display %(prog)s version'),
|
'help' : _("Display %(prog)s version"),
|
||||||
'action' : 'version',
|
'action' : 'version',
|
||||||
'version' : '%(prog)s ' + __version__,
|
'version' : '%(prog)s ' + __version__,
|
||||||
},
|
},
|
||||||
|
@ -83,67 +83,142 @@ action_dict = {
|
||||||
# User #
|
# User #
|
||||||
#############################
|
#############################
|
||||||
'user' : {
|
'user' : {
|
||||||
'category_help' : _('Manage users'),
|
'category_help' : _("Manage users"),
|
||||||
'actions' : {
|
'actions' : {
|
||||||
### user_list()
|
### user_list()
|
||||||
'list' : {
|
'list' : {
|
||||||
'action_help' : _('List users'),
|
'action_help' : _("List users"),
|
||||||
'ldap' : True,
|
'ldap' : True,
|
||||||
'arguments' : {
|
'arguments' : {
|
||||||
'-a' : {
|
'--fields' : {
|
||||||
'full' : '--all',
|
'help' : _("Fields to fetch"),
|
||||||
'help' : _('Display all users'),
|
'nargs' : '+',
|
||||||
'action' : 'store_true'
|
},
|
||||||
|
'-f' : {
|
||||||
|
'full' : '--filter',
|
||||||
|
'help' : _("LDAP filter used to search"),
|
||||||
|
},
|
||||||
|
'-l' : {
|
||||||
|
'full' : '--limit',
|
||||||
|
'help' : _("Maximum number of users fetched"),
|
||||||
|
},
|
||||||
|
'-o' : {
|
||||||
|
'full' : '--offset',
|
||||||
|
'help' : _("Starting number for user fetching"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
### user_add()
|
### user_add()
|
||||||
'add' : {
|
'add' : {
|
||||||
'action_help' : _('Create user'),
|
'action_help' : _("Create user"),
|
||||||
'ldap' : True,
|
'ldap' : True,
|
||||||
'arguments' : {
|
'arguments' : {
|
||||||
'-u' : {
|
'-u' : {
|
||||||
'full' : '--username',
|
'full' : '--username',
|
||||||
'metavar' : _('username'),
|
'help' : _("Must be unique"),
|
||||||
},
|
},
|
||||||
'-f' : {
|
'-f' : {
|
||||||
'full' : '--firstname',
|
'full' : '--firstname',
|
||||||
'metavar' : _('firstname'),
|
|
||||||
},
|
},
|
||||||
'-l' : {
|
'-l' : {
|
||||||
'full' : '--lastname',
|
'full' : '--lastname',
|
||||||
'metavar' : _('lastname'),
|
|
||||||
},
|
},
|
||||||
'-m' : {
|
'-m' : {
|
||||||
'full' : '--mail',
|
'full' : '--mail',
|
||||||
'metavar' : _('mail'),
|
'help' : _("Main mail address, must be unique"),
|
||||||
},
|
},
|
||||||
'-p' : {
|
'-p' : {
|
||||||
'full' : '--password',
|
'full' : '--password',
|
||||||
'metavar' : _('password'),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'info' : {
|
### user_delete()
|
||||||
|
'delete' : {
|
||||||
|
'action_help' : _("Delete user"),
|
||||||
'ldap' : True,
|
'ldap' : True,
|
||||||
'action_help' : _('Get user informations'),
|
'arguments' : {
|
||||||
|
'users' : {
|
||||||
|
'help' : _("Username of users to delete"),
|
||||||
|
'nargs' : '+',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
### user_update()
|
||||||
|
'update' : {
|
||||||
|
'action_help' : _("Update user informations"),
|
||||||
|
'ldap' : True,
|
||||||
|
'arguments' : {
|
||||||
|
'user' : {
|
||||||
|
'help' : _("Username of user to update"),
|
||||||
|
},
|
||||||
|
'-f' : {
|
||||||
|
'full' : '--firstname',
|
||||||
|
},
|
||||||
|
'-l' : {
|
||||||
|
'full' : '--lastname',
|
||||||
|
},
|
||||||
|
'-m' : {
|
||||||
|
'full' : '--mail',
|
||||||
|
},
|
||||||
|
'-cp' : {
|
||||||
|
'full' : '--change-password',
|
||||||
|
'help' : _("New password to set"),
|
||||||
|
'metavar' : 'PASSWORD',
|
||||||
|
},
|
||||||
|
'--add-mailforward' : {
|
||||||
|
'help' : _("Mailforward addresses to add"),
|
||||||
|
'nargs' : '+',
|
||||||
|
'metavar' : 'MAIL',
|
||||||
|
},
|
||||||
|
'--remove-mailforward' : {
|
||||||
|
'help' : _("Mailforward addresses to remove"),
|
||||||
|
'nargs' : '+',
|
||||||
|
'metavar' : 'MAIL',
|
||||||
|
},
|
||||||
|
'-add-mailalias' : {
|
||||||
|
'help' : _("Mail aliases to add"),
|
||||||
|
'nargs' : '+',
|
||||||
|
'metavar' : 'MAIL',
|
||||||
|
},
|
||||||
|
'-remove-mailalias' : {
|
||||||
|
'help' : _("Mail aliases to remove"),
|
||||||
|
'nargs' : '+',
|
||||||
|
'metavar' : 'MAIL',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
### user_info()
|
||||||
|
'info' : {
|
||||||
|
'action_help' : _("Get user informations"),
|
||||||
|
'ldap' : True,
|
||||||
|
'arguments' : {
|
||||||
|
'user' : {
|
||||||
|
'nargs' : '?',
|
||||||
|
},
|
||||||
|
'-m' : {
|
||||||
|
'full' : '--mail',
|
||||||
|
},
|
||||||
|
'-cn' : {
|
||||||
|
'full' : '--fullname',
|
||||||
|
},
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'domain' : {
|
'domain' : {
|
||||||
'category_help' : _('Manage domains'),
|
'category_help' : _("Manage domains"),
|
||||||
'actions' : {}
|
'actions' : {}
|
||||||
},
|
},
|
||||||
'app' : {
|
'app' : {
|
||||||
'category_help' : _('Manage apps'),
|
'category_help' : _("Manage apps"),
|
||||||
'actions' : {}
|
'actions' : {}
|
||||||
},
|
},
|
||||||
'monitor' : {
|
'monitor' : {
|
||||||
'category_help' : _('Monitoring functions'),
|
'category_help' : _("Monitoring functions"),
|
||||||
'actions' : {}
|
'actions' : {}
|
||||||
},
|
},
|
||||||
'tools' : {
|
'tools' : {
|
||||||
'category_help' : _('Specific tools'),
|
'category_help' : _("Specific tools"),
|
||||||
'actions' : {}
|
'actions' : {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,7 +272,7 @@ def parse_dict(action_dict):
|
||||||
# Add arguments
|
# Add arguments
|
||||||
if 'arguments' in action_params:
|
if 'arguments' in action_params:
|
||||||
for arg_name, arg_params in action_params['arguments'].items():
|
for arg_name, arg_params in action_params['arguments'].items():
|
||||||
if arg_params['full']:
|
if 'full' in arg_params:
|
||||||
arg_fullname = arg_params['full']
|
arg_fullname = arg_params['full']
|
||||||
del arg_params['full']
|
del arg_params['full']
|
||||||
parsers[category + '_' + action].add_argument(arg_name, arg_fullname, **arg_params)
|
parsers[category + '_' + action].add_argument(arg_name, arg_fullname, **arg_params)
|
||||||
|
@ -229,11 +304,14 @@ def main():
|
||||||
result = action['args'].func(vars(action['args']), yldap)
|
result = action['args'].func(vars(action['args']), yldap)
|
||||||
else:
|
else:
|
||||||
result = action['args'].func(vars(action['args']))
|
result = action['args'].func(vars(action['args']))
|
||||||
|
#except TypeError:
|
||||||
|
#print(_("Not (yet) implemented function"))
|
||||||
|
#return 1
|
||||||
except YunoHostError, error:
|
except YunoHostError, error:
|
||||||
if not __debug__ :
|
if not __debug__ :
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
if os.isatty(1):
|
if os.isatty(1):
|
||||||
print('\n' + colorize(_('Error: '), 'red') + error.message)
|
print('\n' + colorize(_("Error: "), 'red') + error.message)
|
||||||
else:
|
else:
|
||||||
print(json.dumps({ 'error' : error.message }))
|
print(json.dumps({ 'error' : error.message }))
|
||||||
return error.code
|
return error.code
|
||||||
|
|
Loading…
Add table
Reference in a new issue