implemented 'add_modules' which will call cli method on module to give ability to register custom cli commands

This commit is contained in:
iLLiCiTiT 2021-11-09 16:56:17 +01:00
parent f8e594be80
commit dee8156a0c
2 changed files with 12 additions and 0 deletions

View file

@ -57,6 +57,7 @@ def tray(debug=False):
PypeCommands().launch_tray(debug)
@PypeCommands.add_modules
@main.group(help="Run command line arguments of OpenPype modules")
@click.pass_context
def module(ctx):

View file

@ -41,6 +41,17 @@ class PypeCommands:
user_role = "manager"
settings.main(user_role)
@staticmethod
def add_modules(click_func):
"""Modules/Addons can add their cli commands dynamically."""
from openpype.modules import ModulesManager
manager = ModulesManager()
for module in manager.modules:
if hasattr(module, "cli"):
module.cli(click_func)
return click_func
@staticmethod
def launch_eventservercli(*args):
from openpype_modules.ftrack.ftrack_server.event_server_cli import (