Changeset View
Changeset View
Standalone View
Standalone View
swh/core/cli/__init__.py
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | def main(): | ||||
for entry_point in pkg_resources.iter_entry_points('swh.cli.subcommands'): | for entry_point in pkg_resources.iter_entry_points('swh.cli.subcommands'): | ||||
try: | try: | ||||
cmd = entry_point.load() | cmd = entry_point.load() | ||||
swh.add_command(cmd, name=entry_point.name) | swh.add_command(cmd, name=entry_point.name) | ||||
except Exception as e: | except Exception as e: | ||||
logger.warning('Could not load subcommand %s: %s', | logger.warning('Could not load subcommand %s: %s', | ||||
entry_point.name, str(e)) | entry_point.name, str(e)) | ||||
loader_subcommands = list(pkg_resources.iter_entry_points( | |||||
'swh.cli.loader.subcommands')) | |||||
if len(loader_subcommands) > 0: | |||||
@swh.group() | |||||
@click.pass_context | |||||
def loader(ctx): | |||||
"""Loader subcommand""" | |||||
return ctx | |||||
for entry_point in pkg_resources.iter_entry_points( | |||||
'swh.cli.loader.subcommands'): | |||||
logger.debug(f'swh.cli.subcmd: entry point {entry_point}') | |||||
try: | |||||
logger.debug(f'entrypoint.name: {entry_point.name}') | |||||
cmd = entry_point.load() | |||||
logger.debug(f'cmd: {cmd}') | |||||
loader.add_command(cmd, name=entry_point.name) | |||||
except Exception as e: | |||||
logger.warning( | |||||
f'Could not load subcommand {entry_point.name}: {e}') | |||||
return swh(auto_envvar_prefix='SWH') | return swh(auto_envvar_prefix='SWH') | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
main() | main() |