mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
General: CLI addon command (#5109)
* added 'addon' as alias for 'module' * Changed docstring and description * formatting change
This commit is contained in:
parent
2d0d0305bb
commit
a08e59a5e3
1 changed files with 22 additions and 5 deletions
|
|
@ -5,11 +5,24 @@ import sys
|
|||
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")
|
||||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue