Nukesor / pueue

:stars: Manage your shell commands.
MIT License
4.9k stars 132 forks source link

Enable to remove all groups #428

Closed allencho1222 closed 1 year ago

allencho1222 commented 1 year ago

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

I hope pueue enables us to remove all groups where jobs are not running.

Currently, pueue only supports removing a group by a given group name.

Explain your usecase of the requested feature

I usually use pueue in a script that launches work consisting of multiple pueue jobs.

The work, here, corresponds to the group used by pueue.

However, after launching multiple works, it is quite troublesome to remove all groups if I do not use a tool like awk.

I hope pueue itself has the ability to remove all group names.

Alternatives

No response

Additional context

No response

Nukesor commented 1 year ago

To be honest, I don't think that this should be handled via a new commandline option, as this is a very specific use case.

It sounds like you're heavily relying on scripting to add and remove large amounts of jobs that're then assigned to several groups.

Since I don't see this in a "normal" use case scenario and since this is easily scriptable, you should probably do it that way.

However, I'm open to exposing the list of groups via json, i.e. pueue group -j. That way, you can iterate through all groups check for each group via pueue status -g $group -j status!=running whether there're any tasks and delete it, if they're not.

Nukesor commented 1 year ago

Ping @allencho1222

Would a pueue group -j help you with your scripting setup?

allencho1222 commented 1 year ago

Hi, @Nukesor

I'm sorry, I couldn't understand what you mean.

There's no option -j for pueue group.

Does it mean that are you willing to support (make) the option like pueue group -j?

If such option is available, it would be nice.

I currently clean groups (assuming jobs are not running) to re-launch the script with the same group names:

pueue group | awk '{print $2}' | xargs -n 1 pueue group remove

Thank you.

Nukesor commented 1 year ago

Yes, I'm offering to add a -j/--json option for the pueue group subcommand, so it's easier to do scripting :)

allencho1222 commented 1 year ago

Hi, @Nukesor

Thank you. I really appreciate it.

Nukesor commented 1 year ago

I'll track this in the newly created issue to avoid confusion :)