Skip to content

Commit

Permalink
General: CLI addon command (#5109)
Browse files Browse the repository at this point in the history
* added 'addon' as alias for 'module'

* Changed docstring and description

* formatting change
  • Loading branch information
iLLiCiTiT committed Jun 8, 2023
1 parent 1d76883 commit 7a1ad7b
Showing 1 changed file with 22 additions and 5 deletions.
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

0 comments on commit 7a1ad7b

Please sign in to comment.