feat: adding list_by command

This commit is contained in:
2026-04-03 15:23:58 +02:00
parent 10aabc8c0a
commit 12de0f1b6c
3 changed files with 46 additions and 5 deletions

28
commands/list_tasks_by.go Normal file
View File

@@ -0,0 +1,28 @@
package commands
import (
"fmt"
"gotask-cli/models"
"gotask-cli/utils"
)
func ListTasksBy(status string, backlog []models.Task) {
var backlogToDisplay []models.Task
var statusID models.Status
for i, v := range models.StatusName {
if v == status {
statusID = i
}
}
for _, v := range backlog {
if v.Status == models.Status(statusID) {
backlogToDisplay = append(backlogToDisplay, v)
}
}
if len(backlogToDisplay) > 0 {
utils.PrintTasksAsATable(backlogToDisplay)
} else {
fmt.Printf("No tasks with the status [%s]", status)
}
}