Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General: CLI addon command #5109

Merged
merged 3 commits into from
Jun 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 22 additions & 5 deletions openpype/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@
import code
import click

# import sys
from .pype_commands import PypeCommands


@click.group(invoke_without_command=True)
class AliasedGroup(click.Group):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._aliases = {}

def set_alias(self, src_name, dst_name):
self._aliases[dst_name] = src_name

def get_command(self, ctx, cmd_name):
if cmd_name in self._aliases:
cmd_name = self._aliases[cmd_name]
return super().get_command(ctx, cmd_name)


@click.group(cls=AliasedGroup, invoke_without_command=True)
@click.pass_context
@click.option("--use-version",
expose_value=False, help="use specified version")
Expand Down Expand Up @@ -58,16 +71,20 @@ def tray():


@PypeCommands.add_modules
@main.group(help="Run command line arguments of OpenPype modules")
@main.group(help="Run command line arguments of OpenPype addons")
@click.pass_context
def module(ctx):
"""Module specific commands created dynamically.
"""Addon specific commands created dynamically.

These commands are generated dynamically by currently loaded addon/modules.
These commands are generated dynamically by currently loaded addons.
"""
pass


# Add 'addon' as alias for module
main.set_alias("module", "addon")


@main.command()
@click.option("--ftrack-url", envvar="FTRACK_SERVER",
help="Ftrack server url")
Expand Down