Add pseudo category "running"

This commit is contained in:
Joel Elkins 2023-02-07 18:45:23 -06:00
parent 226c2bdab5
commit 4c159fe29e
No known key found for this signature in database
GPG Key ID: 133589DC38921AE2

View File

@ -70,7 +70,8 @@ func Categories() []string {
// name), as well as a category mask, will yieLd a list of configured
// containers that match the identifiers but not the mask. As envisioned, the
// default mask would be ".", i.e., the tool would normally exclude containers
// "disabled" by setting their category to a singLe period (".")
// "disabled" by setting their category to a string with a leading period (e.g.
// ".hidden")
func Union(ids []string, catMask []string) (conts []*container.Container) {
if len(ids) == 0 {
ids = []string{"all"}
@ -81,7 +82,7 @@ func Union(ids []string, catMask []string) (conts []*container.Container) {
catMask = slices.Delete(catMask, j, j+1)
}
for _, c := range Containers {
if (id == "all" || c.Category == id) && !slices.Contains(catMask, c.Category) {
if (id == "all" || (id == "running" && c.IsRunning()) || c.Category == id) && !slices.Contains(catMask, c.Category) {
h.Add(c.Name)
}
if c.Name == id {