forked from uncloud/uncloud
Move all files to _etc_based
This commit is contained in:
parent
10f09c7115
commit
3cf3439f1c
116 changed files with 1 additions and 0 deletions
23
uncloud_etcd_based/uncloud/cli/main.py
Normal file
23
uncloud_etcd_based/uncloud/cli/main.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import importlib
|
||||
|
||||
arg_parser = argparse.ArgumentParser('cli', add_help=False)
|
||||
subparser = arg_parser.add_subparsers(dest='subcommand')
|
||||
|
||||
for component in ['user', 'host', 'image', 'network', 'vm']:
|
||||
module = importlib.import_module('uncloud.cli.{}'.format(component))
|
||||
parser = getattr(module, 'arg_parser')
|
||||
subparser.add_parser(name=parser.prog, parents=[parser])
|
||||
|
||||
|
||||
def main(arguments):
|
||||
if not arguments['subcommand']:
|
||||
arg_parser.print_help()
|
||||
else:
|
||||
name = arguments.pop('subcommand')
|
||||
arguments.pop('debug')
|
||||
mod = importlib.import_module('uncloud.cli.{}'.format(name))
|
||||
_main = getattr(mod, 'main')
|
||||
_main(**arguments)
|
||||
Loading…
Add table
Add a link
Reference in a new issue