mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
User function file init
This commit is contained in:
parent
60a27e4a1f
commit
a24ba260c3
2 changed files with 8 additions and 1 deletions
5
lib/yunohost_user.py
Normal file
5
lib/yunohost_user.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
def user_list(args):
|
||||
print vars(args)
|
4
yunohost
4
yunohost
|
@ -3,6 +3,7 @@
|
|||
|
||||
import sys
|
||||
import argparse
|
||||
sys.path.append('lib')
|
||||
|
||||
# Version of YunoHost
|
||||
version = '2.0'
|
||||
|
@ -82,13 +83,14 @@ parsers = subparsers_category = subparsers_action = dict()
|
|||
Turn above array into subparsers (e.g. parsers['user_list'])
|
||||
and assign functions related to (e.g. user_list())
|
||||
"""
|
||||
|
||||
for category, info in parser_array.items():
|
||||
subparsers_category[category] = subparsers.add_parser(category, help = info['help'])
|
||||
subparsers_action[category] = subparsers_category[category].add_subparsers()
|
||||
for action, helper in info['actions'].items():
|
||||
parsers[category + '_' + action] = subparsers_action[category].add_parser(action, help = helper)
|
||||
try:
|
||||
parsers[category + '_' + action].set_defaults(func=str2fun(category + '_' + action))
|
||||
parsers[category + '_' + action].set_defaults(func = str2fun('yunohost_' + category + '.' + category + '_' + action))
|
||||
except AttributeError:
|
||||
print 'Error: Function ' + category + '_' + action + '() has not been defined'
|
||||
sys.exit(1)
|
||||
|
|
Loading…
Add table
Reference in a new issue