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

CLI missing argument for targets #334

Open
aardschok opened this issue Feb 15, 2018 · 3 comments
Open

CLI missing argument for targets #334

aardschok opened this issue Feb 15, 2018 · 3 comments

Comments

@aardschok
Copy link
Contributor

Issue:

We have setup a publishing approach which uses targets so we only get those plugins when the target is set to X. When attempting to run pyblish publish --targets X we are notified that there is no such option as --targets.

After looking in the code we found that the publish function has the keyword argument targets but the CLI module has no integration of it.

Motivation

Update CLI to support targets

@tokejepsen
Copy link
Member

👍

@aardschok
Copy link
Contributor Author

When going over the amount of kwargs which needed to be set I tested a more global approach thanks to @BigRoy.

Instead following the trail of targets throughout pyblish-base and pyblish-qml I have introduced an environment variable called PYBLISH_TARGETS which is being set in our Avalon CLI.

Snippet:

if kwargs.targets:
    os.environ["PYBLISH_TARGETS"] = os.pathsep.join(kwargs.targets)

In the api module of pyblish-base I ensured the environment variable is being checked and process in the __init__ function with the following snippet:

# Register targets for current session
for t in os.environ.get("PYBLISH_TARGETS", "").split(os.pathsep):
    if t:
        register_target(t)

I did however implement a click.option for targets to be passed on the publish function to ensure that, when the flag --nogui is used, you are still able to pass on the targets.

Any thoughts on this approach?

@aardschok
Copy link
Contributor Author

Full code can be viewed here:
https://github.com/aardschok/pyblish-base/tree/334

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants