mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
example addon has cli commands
This commit is contained in:
parent
88ac91c82c
commit
2f4ee4447e
1 changed files with 32 additions and 1 deletions
|
|
@ -8,10 +8,12 @@ in global space here until are required or used.
|
|||
"""
|
||||
|
||||
import os
|
||||
import click
|
||||
|
||||
from openpype.modules import (
|
||||
JsonFilesSettingsDef,
|
||||
OpenPypeAddOn
|
||||
OpenPypeAddOn,
|
||||
ModulesManager
|
||||
)
|
||||
# Import interface defined by this addon to be able find other addons using it
|
||||
from openpype_interfaces import (
|
||||
|
|
@ -130,3 +132,32 @@ class ExampleAddon(OpenPypeAddOn, IPluginPaths, ITrayAction):
|
|||
return {
|
||||
"publish": [os.path.join(current_dir, "plugins", "publish")]
|
||||
}
|
||||
|
||||
def cli(self, click_group):
|
||||
click_group.add_command(cli_main)
|
||||
|
||||
|
||||
@click.group(ExampleAddon.name, help="Example addon dynamic cli commands.")
|
||||
def cli_main():
|
||||
pass
|
||||
|
||||
|
||||
@cli_main.command()
|
||||
def nothing():
|
||||
"""Does nothing but print a message."""
|
||||
print("You've triggered \"nothing\" command.")
|
||||
|
||||
|
||||
@cli_main.command()
|
||||
def show_dialog():
|
||||
"""Show ExampleAddon dialog.
|
||||
|
||||
We don't have access to addon directly through cli so we have to create
|
||||
it again.
|
||||
"""
|
||||
from openpype.tools.utils.lib import qt_app_context
|
||||
|
||||
manager = ModulesManager()
|
||||
example_addon = manager.modules_by_name[ExampleAddon.name]
|
||||
with qt_app_context():
|
||||
example_addon.show_dialog()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue