-
Notifications
You must be signed in to change notification settings - Fork 135
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
Add support for pre
and post
scripts/commands
#451
Comments
I see https://github.com/Nukesor/pueue/wiki/Miscellaneous#aliases could help here as well |
I thought a lot about this over the course of the last few days. This feature would add a lot of complexity:
This change would add heaps of functionality, that would be better suited for a wrapper script, or a project with a better UI and the goal to provide a task scheduler/executor with advanced functionality. Pueues goal always was and still is to be kind of minimalistic, but very good at what it does. |
I won't deny it adds complexity, we may take shortcuts if that helps make it doable:
We could simply return the status code.
Status only ?
Those pre hooks are mainly gates to prevent or influence the scheduler. I think it would be fine to only consider their status. On the other hand, why not letting the user decide and pre/post-pending the pre/post hooks to the regular log output ?
For the |
This will result in a bad UX, since users wouldn't know which part of their setup failed. I.e. was it the pre/post or the actual command that failed. This needs to be clearly communicated.
This is also critical. If anything in those scripts goes wrong, the user needs to have easy access to clearly visible output that allows them to debug any issues.
If that's the case, what exactly keeps you from doing a simple Your example from above would then look like this:
This is actually easier to type, shorter and more versatile, as you can utilize everything the shell offers. |
Closing for now. I'll re-open if there's additional feedback. |
A detailed description of the feature you would like to see added.
Sometimes, you need to perform a list of tasks and ensure you don't spam tasks too quickly. Or one may need to run tasks that depend on an external even to occur and create a file for instance.
This can also be considered as having to wait for a condition before executing a task. Such a condition would be "ensure this
find
call returns something" or "wait for sleep 1000" to return with a success status.The idea would be to add a global option (overridable per group, overrridable per task) that would allow running a command
pre
orpost
running a task. This would apply to all tasks.With
pre
set assleep 10
for a group, the task would first run thepre
script and wait for an exit. If the status is0
, we execute the task as it is done today. If the status is not0
, the task is aborted.For the use case when the user needs to wait for an external event, a user script can be crafted to loop and wait for while and return
0
when the condition is met, or "give up" after a while and return an error status code.Here are some examples: (I am using
alias q=pueue
)This would likely require a new state that could be called
waiting
orpre
andpost
.Explain your usecase of the requested feature
Consider for instance a scenario where you need to send thousands of curl request to an API and you want to ensure that you don't exceed whatever cap the targeted web service implements.
Alternatives
Currently, there would be options that are less elegant:
sleep <N>
between each task but this bloats the tasks lists and the overviewssleep N
Additional context
There is already the
--after
flag for theadd
command but it relates to other "single" tasks and not a task/script that would run before/after each task.The text was updated successfully, but these errors were encountered: