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

Example for combining jobs with args #122

Closed
grommasdietz opened this issue Feb 28, 2024 · 1 comment
Closed

Example for combining jobs with args #122

grommasdietz opened this issue Feb 28, 2024 · 1 comment
Assignees

Comments

@grommasdietz
Copy link

Hello again

hopefully not disturbing and maybe helpful for others as well: Is there a way to combine jobs with passing args?
For example, commands/thumbnails.php:

<?php

use Bnomei\Janitor;
use Kirby\CLI\CLI;

return [
    'description' => 'Render and create thumbnails',
    'args' => [] + Janitor::ARGS, // page, file, user, site, data, model
    'command' => static function ($cli): void {
        $pageId = $cli->arg('page');
        $page = page($pageId);

        janitor()->command('janitor:render --quiet');
        janitor()->command('janitor:thumbs --quiet');

        janitor()->data($cli->arg('command'), [
            'status' => 200,
            'message' => 'Rendered pages and generated thumbs successfully for page: ' . $page->title(),
        ]);
    }
];

And referencing in blueprint like:

thumbnails:
  type: janitor
  command: 'thumbnails' # commands/thumbnails
  label:
    en: Create thumbnails
    de: Thumbnails erstellen

Is working fine, but when trying to only render and create thumbnails for current page, it seems not to work at all:

        janitor()->command('janitor:render --query page --quiet');
        janitor()->command('janitor:thumbs --quiet'); // do we need to pass '--page page' in this case?

I’m thankful for any hints.

@grommasdietz grommasdietz reopened this Mar 7, 2024
@bnomei bnomei self-assigned this May 24, 2024
@bnomei
Copy link
Owner

bnomei commented May 24, 2024

@grommasdietz

yes for both you would need to provide the targeted page using the cli param, like...

janitor()->command('janitor:render --query "page://mypageuuid" --quiet');
janitor()->command('janitor:thumbs --page "page://mypageuuid" --quiet');

either uuid or plain id will do

@bnomei bnomei closed this as completed May 24, 2024
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