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

Return schedule as array of objects / arrays #28

Closed
turtle0x1 opened this issue Aug 6, 2022 · 8 comments
Closed

Return schedule as array of objects / arrays #28

turtle0x1 opened this issue Aug 6, 2022 · 8 comments
Milestone

Comments

@turtle0x1
Copy link

turtle0x1 commented Aug 6, 2022

Description
Its cool that you can run vendor/bin/crunz s:l but it would be really good if we could see these jobs displayed on a web interface.

Unfortunately I'm not quite sure how to approach this issue so im requesting it but cant produce a PR (which I know is rude sorry).

Happy to give it a shot but will need some pointers 😄

@PabloKowalczyk
Copy link
Member

Will JSON output be ok?

@turtle0x1
Copy link
Author

JSON would work better if not possible to call pragmatically withoutout opening a shell process.

Ideally what Im trying todo is something like;

$crunz = new Crunz();
$schedules = $crunz->getSchedule();
// [ Task(), Task(), Task() ]

@PabloKowalczyk
Copy link
Member

JSON would work better if not possible to call pragmatically withoutout opening a shell process.

Currently it won't be easy, because there is no place where developer can hook after collecting all tasks.
Will --format option on schedule:list help?

@turtle0x1
Copy link
Author

turtle0x1 commented Aug 13, 2022

Yeah because you can do some hacky stuff like

$results = json_decode(shell_exec("vendor/bin/crunz s:l --format json"))

it might be worth thinking about the case where an exception / error happens as well and what will be out put on that case!

If the errors aren't JSON you'd have todo something like;

$results = json_decode(shell_exec("vendor/bin/crunz s:l --format json"))
// Might not have access to JSON_THROW_EXCEPTION
if(json_last_error()){
     // If when crunz errors the exception isn't JSON we wont be able to parse a real error message
     throw new \Exception("Something went wrong in the crunz script")
}

@PabloKowalczyk
Copy link
Member

Ok, give me few days :)

it might be worth thinking about the case where an exception / error happens as well and what will be out put on that case!

In that case you should rely on process exit code or use symfony/process and mustRun (https://symfony.com/doc/current/components/process.html).

@PabloKowalczyk
Copy link
Member

Ok, check PR #31.

@turtle0x1
Copy link
Author

Awesome, thank you 😄 Will try to give this a test over the next couple of days!

@PabloKowalczyk
Copy link
Member

PabloKowalczyk commented Oct 3, 2022

Fixed by #31.

@PabloKowalczyk PabloKowalczyk added this to the v3.4 milestone Oct 3, 2022
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