aztk/aztk_cli/plugins.py

31 строка
973 B
Python
Исходник Обычный вид История

2018-02-27 03:36:31 +03:00
import argparse
import typing
2018-03-06 04:18:47 +03:00
from aztk_cli import log
2018-02-27 03:36:31 +03:00
from aztk.models.plugins.internal import plugin_manager
def setup_parser(parser: argparse.ArgumentParser):
pass
def execute(args: typing.NamedTuple):
plugins = plugin_manager.plugins
log.info("------------------------------------------------------")
log.info(" Plugins (%i available)",len(plugins))
log.info("------------------------------------------------------")
for name, plugin in plugins.items():
log.info("- %s", name)
args = plugin_manager.get_args_for(plugin)
if args:
log.info(" Arguments:")
for arg in args.values():
log.info(" - %s", arg_str(arg))
else:
log.info(" Arguments: None")
log.info("")
def arg_str(arg):
required = "Required" if arg.required else "Optional(Default: {0})".format(arg.default)
return "{0}: {1}".format(arg.name, required)