Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5928 from ynput/feature/wrap-click
Browse files Browse the repository at this point in the history
Chore: Wrapper for click proposal
  • Loading branch information
iLLiCiTiT authored Feb 5, 2024
2 parents 5f0944e + ac46cbe commit 77f59eb
Show file tree
Hide file tree
Showing 10 changed files with 446 additions and 64 deletions.
13 changes: 8 additions & 5 deletions openpype/hosts/standalonepublisher/addon.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import os

import click

from openpype.lib import get_openpype_execute_args
from openpype.lib.execute import run_detached_process
from openpype.modules import OpenPypeModule, ITrayAction, IHostAddon
from openpype.modules import (
click_wrap,
OpenPypeModule,
ITrayAction,
IHostAddon,
)

STANDALONEPUBLISH_ROOT_DIR = os.path.dirname(os.path.abspath(__file__))

Expand Down Expand Up @@ -37,10 +40,10 @@ def run_standalone_publisher(self):
run_detached_process(args)

def cli(self, click_group):
click_group.add_command(cli_main)
click_group.add_command(cli_main.to_click_obj())


@click.group(
@click_wrap.group(
StandAlonePublishAddon.name,
help="StandalonePublisher related commands.")
def cli_main():
Expand Down
15 changes: 10 additions & 5 deletions openpype/hosts/traypublisher/addon.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import os

import click

from openpype.lib import get_openpype_execute_args
from openpype.lib.execute import run_detached_process
from openpype.modules import OpenPypeModule, ITrayAction, IHostAddon
from openpype.modules import (
click_wrap,
OpenPypeModule,
ITrayAction,
IHostAddon,
)

TRAYPUBLISH_ROOT_DIR = os.path.dirname(os.path.abspath(__file__))

Expand Down Expand Up @@ -38,10 +41,12 @@ def run_traypublisher(self):
run_detached_process(args)

def cli(self, click_group):
click_group.add_command(cli_main)
click_group.add_command(cli_main.to_click_obj())


@click.group(TrayPublishAddon.name, help="TrayPublisher related commands.")
@click_wrap.group(
TrayPublishAddon.name,
help="TrayPublisher related commands.")
def cli_main():
pass

Expand Down
34 changes: 16 additions & 18 deletions openpype/hosts/webpublisher/addon.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import os

import click

from openpype.modules import OpenPypeModule, IHostAddon
from openpype.modules import click_wrap, OpenPypeModule, IHostAddon

WEBPUBLISHER_ROOT_DIR = os.path.dirname(os.path.abspath(__file__))

Expand Down Expand Up @@ -38,21 +36,21 @@ def headless_publish(self, log, close_plugin_name=None, is_test=False):
)

def cli(self, click_group):
click_group.add_command(cli_main)
click_group.add_command(cli_main.to_click_obj())


@click.group(
@click_wrap.group(
WebpublisherAddon.name,
help="Webpublisher related commands.")
def cli_main():
pass


@cli_main.command()
@click.argument("path")
@click.option("-u", "--user", help="User email address")
@click.option("-p", "--project", help="Project")
@click.option("-t", "--targets", help="Targets", default=None,
@click_wrap.argument("path")
@click_wrap.option("-u", "--user", help="User email address")
@click_wrap.option("-p", "--project", help="Project")
@click_wrap.option("-t", "--targets", help="Targets", default=None,
multiple=True)
def publish(project, path, user=None, targets=None):
"""Start publishing (Inner command).
Expand All @@ -67,11 +65,11 @@ def publish(project, path, user=None, targets=None):


@cli_main.command()
@click.argument("path")
@click.option("-p", "--project", help="Project")
@click.option("-h", "--host", help="Host")
@click.option("-u", "--user", help="User email address")
@click.option("-t", "--targets", help="Targets", default=None,
@click_wrap.argument("path")
@click_wrap.option("-p", "--project", help="Project")
@click_wrap.option("-h", "--host", help="Host")
@click_wrap.option("-u", "--user", help="User email address")
@click_wrap.option("-t", "--targets", help="Targets", default=None,
multiple=True)
def publishfromapp(project, path, host, user=None, targets=None):
"""Start publishing through application (Inner command).
Expand All @@ -86,10 +84,10 @@ def publishfromapp(project, path, host, user=None, targets=None):


@cli_main.command()
@click.option("-e", "--executable", help="Executable")
@click.option("-u", "--upload_dir", help="Upload dir")
@click.option("-h", "--host", help="Host", default=None)
@click.option("-p", "--port", help="Port", default=None)
@click_wrap.option("-e", "--executable", help="Executable")
@click_wrap.option("-u", "--upload_dir", help="Upload dir")
@click_wrap.option("-h", "--host", help="Host", default=None)
@click_wrap.option("-p", "--port", help="Port", default=None)
def webserver(executable, upload_dir, host=None, port=None):
"""Start service for communication with Webpublish Front end.
Expand Down
3 changes: 3 additions & 0 deletions openpype/modules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from . import click_wrap
from .interfaces import (
ILaunchHookPaths,
IPluginPaths,
Expand Down Expand Up @@ -28,6 +29,8 @@


__all__ = (
"click_wrap",

"ILaunchHookPaths",
"IPluginPaths",
"ITrayModule",
Expand Down
Loading

0 comments on commit 77f59eb

Please sign in to comment.