Nukesor / pueue

:stars: Manage your shell commands.
MIT License
4.69k stars 128 forks source link

Reset specific group #482

Closed amiroslaw closed 1 week ago

amiroslaw commented 7 months ago

A detailed description of the feature you would like to see added.

I was surprised that I can't reset or remove all tasks from a specific group. I'm not sure if it wasn't implemented in this issue, but there is no parameter --group in the reset option. I use pueue 3.3.2

Explain your usecase of the requested feature

I want to clean up jobs in a group with one command. It would be nice to have pueue reset --group or pueue remove --group

Alternatives

No response

Additional context

No response

Nukesor commented 7 months ago

This is due to the fact that pueue reset is a very old feature and actually resets all tasks. Groups were added years later and until now nobody requested such a feature.

In general, I think this could be a nice quality of life feature. I'm not sure how to implement it yet though. As noted before, the current reset functionality is global, which includes a global lock of all state to prevent tasks from being spawned while resetting the state. The reset operation might take a little while, since tasks need to be stopped and cleaned up, which isn't an instant operation.

For this to work on a group-level, we would have to lock by groups and cover edge-cases such as "What happens if a full reset is triggered while a group reset is running" and vice versa. This needs to be properly designed. Maybe we need to refactor the current global logic as well (maybe we could make the global reset use group resets under the hood).

I'll eventually take a look at this, but I'm currently moving and I'll have to renovate my old + new home. I'll probably not get to implement this in the next few months :sweat_smile:.

Nukesor commented 7 months ago

For the time being, there's pueue clean -g, but this obviously only cleans up finished tasks.

Nukesor commented 2 weeks ago

With https://github.com/Nukesor/pueue/pull/547 landing, this change should now become significantly easier. The whole process handling logic has been streamlined a lot.

PRs welcome.